var Content=React.createClass({
render: function(){
return content
}
});
var Comment=React.createClass({
getInitialState: function(){
return {
name:['tim','John','Jack']
}
},
render: function(){
var options=[];
for(var i=0 ;i<=this.state.name.length; i++){
options.push();
}
return
}
});
上面的代码效果出来了,但是报了下面这个错,刚刚接触react,有点儿不理解,还请各位指教:
Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of Comment. See https://fb.me/react-warning-keys for more information.
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
options.push(<option key={i} value={i}>{this.state.name[i]}</option>);
人家链接都给你了,你不看的?