我的实际Javascript代码如下:
var schoolsData = new Array();
myDB.schools
.each(function(school) {
console.log('"' + school.title + '" wird auf den Array gepusht.');
schoolsData.push(new Array(school.title, schools.schoolnumber, school.address, school.principal, school.email, school.creationdate, school.lastupdate, school.comment));
});
var SchoolsRender = React.createClass({
render: function() {
return (
<tr>
{this.props.list.map(function(listValue){
return <td>{listValue}</td>;
})}
</tr>
)
}
});
ReactDOM.render(<SchoolsRender list={schoolsData} />, document.getElementById('schoolsDATA'));如您所见,我正在尝试从本地IndexedDB数据库(我正在使用dexieJS)中提取数据,并通过ReactJS将其放入一个表元素中,但什么也没有出现。重点在哪里?
编辑:我认为问题基本上是,我试图输出那个3D数组。有什么简单优雅的解决方案吗?
发布于 2016-05-17 10:46:15
添加另一个组件RowRender以呈现单行。相应地修改SchoolsRender组件。
var RowRender = React.createClass({
render: function() {
return (
<tr>
<td>{this.props.title}</td>
<td>{this.props.schoolnumber}</td>
<td>{this.props.address}</td>
<td>{this.props.principal}</td>
</tr>
)
}
});
var SchoolsRender = React.createClass({
render: function() {
return (
<table>
{this.props.list.map(function(listValue,index){
return <RowRender key={index} title={listValue.title} schoolnumber={listValue.schoolnumber} address={listValue.address} title={listValue.address} />;
})}
</table>
)
}
});https://stackoverflow.com/questions/37273721
复制相似问题