0
我的代碼有什麼問題?找不到任何有意義的錯誤說明,停留20分鐘。無法渲染複選框
class HelloWidget extends React.Component {
constructor(props) {
super(props);
}
renderResult(data){
return(
data.fruits.map(obj =>
<select>
<label>{obj.name}</label>
<input type="checkbox" defaultChecked={obj.value} />
</select>
)
)
}
render() {
//assume data came from API
cosnt data = {
"fruits": [
{"id":1,"name":"Durian","value":true},
{"id":2,"name":"Banana","value":true},
{"id":3,"name":"Mango","value":false}
]
}
return (<div>{this.renderResult(data)}</div>)
}
}
創建一個搗鼓調試https://jsfiddle.net/w9r6Lqvh/