今天讲一下Image,其实在React Native里面Image的使用方式多种多样啊。现在贴一下代码来讲解一下
<Image source={
{ uri: i }} style={
{ height: array[key] * (width - _getWidth(45)) / 2, width: (width - _getWidth(45)) / 2, resizeMode: 'cover' }} />
其中的source里面有俩种使用方式一种是这个网络图片的,这个就没什么好说吧。uri加上连接。
其中讲另一个问题就是require('../../img/company.png')的这个方式记住了- -这个东西里面的连接和require是不能分开的。如果分开了聚会报错了。
所以你想要给image设置底图应该使用三目运算法去解决。比如这样把
<Image source={i?{ uri: i }:require('../../img/company.png')} style={
{ height: array[key] * (width - _getWidth(45)) / 2, width: (width - _