美文网首页
react native如何获取原生android ios的图片

react native如何获取原生android ios的图片

作者: _悟_空 | 来源:发表于2019-11-13 15:23 被阅读0次

react 获取android 工程里的图片

获取android mipmap目录下的图片

        <Image
          resizeMode="contain"
          source={{ uri: 'mipmap/splash_icon' }}//splash_icon为图片名称 比如splash_icon.png
          style={{ marginTop: pTd(84), height: pTd(130), width: pTd(500) }} //不能写到styles文件里面,否则无效
        />

获取android drawable 目录下的图片

        <Image
          resizeMode="contain"
          source={{ uri: 'splash_icon' }}//splash_icon为图片名称 比如splash_icon.png
          style={{ marginTop: pTd(84), height: pTd(130), width: pTd(500) }} //不能写到styles文件里面,否则无效
        />

react 获取ios assets/images目录下的图片

        <Image
          resizeMode="contain"
          source={{ uri: 'splash_icon' }}//splash_icon为图片名称 比如splash_icon.png
          style={{ marginTop: pTd(84), height: pTd(130), width: pTd(500) }} //不能写到styles文件里面,否则无效
        />

相关文章

网友评论

      本文标题:react native如何获取原生android ios的图片

      本文链接:https://www.haomeiwen.com/subject/jjohictx.html