【发布时间】:2016-05-16 17:13:44
【问题描述】:
我正在尝试为我的选择列表创建一个选项:
getMarkOptions: function () {
var options = this.props.renderProps;
return options.map(function (mark, i) {
return <option
key={i}
value={mark}>
{mark}
</option>
});
},
render: function () {
console.log('mark editor ' + this.props);
var selectedMark = this.props.value,
row = this.props.data,
highlightCurrentDay = this.props.highlight ? 'edit-select__currentDay':'';
return (
<select
value={selectedMark}
ref="selectMark"
className={"edit-select form-control " + highlightCurrentDay}
onChange={this.onChange}
>
{this.getMarkOptions()}
</select>
);
}
数据:
var marks = [
{"id": 1, "caption": "/", "code": "/", "meaning": "Present (AM)", "isStandardCode": true},
{"id": 2, "caption": "\\", "code": "\\", "meaning": "Present (PM)", "isStandardCode": true},
{"id": 3, "caption": "B", "code": "B", "meaning": "Educated off site", "isStandardCode": true},
{"id": 4, "caption": "C", "code": "C", "meaning": "Other Authorised Circumstances", "isStandardCode": true},
{"id": 5, "caption": "D", "code": "D", "meaning": "Dual registration", "isStandardCode": true}
];
我不断收到错误:
未处理的拒绝不变违规:对象作为 React 子项无效(发现:具有键 {id、标题、代码、含义、isStandardCode} 的对象)。如果您打算渲染一组子项,请改用数组或使用 React 附加组件中的 createFragment(object) 包装对象。
谁能帮忙?
【问题讨论】:
标签: reactjs