【发布时间】:2018-12-06 22:48:02
【问题描述】:
这是我的代码。
class Squence extends Component {
constructor(props){
super(props)
this.data = []
}
render() {
for(var i = 0; i < 3; i++){
this.data.push(i);
}
return (
<View>
{this.data.map((item) => {
<View key={item} style={{height: 20, width: 20, backgroundColor: 'red', marginLeft: 3, marginTop: 3}}><Text>{item}</Text></View>
})}
</View>
);
}
}
export default Squence;
我认为我的代码没有错,但它不起作用! 什么原因? 我用map方法有错吗?
【问题讨论】:
-
您需要告诉我们您所说的“不起作用”是什么意思。
标签: reactjs react-native