[英]react-native-swiper does not show dynamic images
我的問題是我的刷卡器不顯示圖像。 有刷卡器和刷卡器中的點,但未顯示圖像。 我對本機很陌生。 這是我的代碼:
import React from 'react';
import {
StyleSheet,
View,
Image,
Text
} from 'react-native';
import Swiper from 'react-native-swiper';
export default class HomeScreen extends React.Component {
state = {
data: []
}
componentDidMount = () => {
this.setState({
data: this.props.navigation.getParam('data', 'NO-DATA')
});
}
render() {
return (
<View style={styles.container}>
<Swiper
style = {styles.swiper }
>
{
this.state.data.map( (item, i) => {
<View>
<Text> {item.url} </Text>
<Image
style={{width: 200, height: 200}}
source={{uri: item.url}}
/>
</View>
})
}
</Swiper>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'red',
alignItems: 'center',
justifyContent: 'center',
},
swiper: {
width: 200,
height: 200
}
});
問題不僅在於圖像,還包括文本等。我是否缺少某些東西?
返回缺少在地圖內添加它。
{
this.state.data.map && this.state.data.map( (item, i) => {
return(
<View>
<Text> {item.url} </Text>
<Image
style={{width: 200, height: 200}}
source={{uri: item.url}}
/>
</View>)
})
}
還是沒有回報。 如果使用(此括號,則無需添加返回
{
this.state.data.map && this.state.data.map( (item, i) => (
<View>
<Text> {item.url} </Text>
<Image
style={{width: 200, height: 200}}
source={{uri: item.url}}
/>
</View>)
))
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.