【发布时间】:2022-01-06 08:53:48
【问题描述】:
我正在使用 Yelp Api,我尝试搜索餐厅,但我遇到了餐厅图片问题 我没有问题地获得名称和评级,但图像是第一次显示,但是当我重新加载我的应用程序时出现此错误:uri 的值不能从双精度转换为字符串
代码如下:
const RestaurantItems=(props)=>{
return(
<ScrollView>
<View style={props.theme=='light'?styles.container:styles.darkContainer}>
{props.restaurantsData.map((item,index)=>(
<View style={{marginTop:20}} key={index}>
<View style={styles.Img}>
<Image source={{uri:item.image_url}}style={{width:'100%',height:180}} />
</View>
<View style={{paddingLeft:10,marginTop:15,flexDirection:"row",justifyContent:'space-between',alignItems:"center"}}>
<View>
<Text style={[{fontSize:19,fontWeight:"700"},props.theme=='dark'?{color:'white'}:{color:'black'}]}>{item.name}</Text>
<Text style={{color:'#717171'}}>35-45 m</Text>
</View>
<View style={{marginRight:10,backgroundColor:"#eee",paddingHorizontal:7,borderRadius:30}}>
<Text style={{fontSize:19,fontWeight:"500"}}>{item.rating}</Text>
</View>
</View>
</View>
))}
</View>
</ScrollView>
)}```
【问题讨论】:
标签: react-native api yelp-fusion-api