如何解决我想显示平面列表数据,但不显示某些数据,尤其是图像
我用它来从服务器中收集数据
getPopularProduct = async () => {
const url = `https://swissmade.direct/wp-json/swissmade/home/popular`;
fetch(url)
.then(response => response.json())
.then((responseJson) => {
console.log(responseJson.products.thumbnail,"details")
if(responseJson.error == false){
this.setState({
dataSourcePopularProduct: responseJson.products,//isLoading: false,})
}
})
.catch((error) => {
console.log(error)
})
}
this the blank space imag,这是平面列表和渲染项目
renderPopularProduct = ({ item }) => {
const entities = new Entities();
var id = item.pid;
var img = { 'uri': item.thumbnail };
return (
<TouchableOpacity onPress={() => this.props.navigation.navigate('ProductDetails',{ id })}>
<View style={styles.GalleryBox}>
<View style={styles.GalleryImg} onPress={() => this.props.navigation.navigate("ProductDetails")}>
<Image source={img} style={styles.SingelImg} largeHeap="true"/>
</View>
<View style={styles.GalleryText}>
<Text style={styles.userNmae}>{item.title}</Text>
</View>
<View style={styles.amount}>
<Text style={styles.userNmae}>{entities.decode(item.currency)} {item.price}</Text>
</View>
</View>
</TouchableOpacity>
)
}
<FlatList
data={this.state.dataSourcePopularProduct}
renderItem={this.renderPopularProduct}
keyExtractor={(item,index) => index}
horizontal={true}
showsHorizontalScrollIndicator={false}
/>
和样式表
SingelImg: {
width: '150%',height: '120%',//resizeMode: 'cover',marginLeft: -25
},
这样,我使用平面列表,但是当它显示某些数据(尤其是图像)丢失时。但是我的API会返回所有正确的数据。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。