0
我将数据渲染到表中以创建动态表。 但tbody数据正在从表格中渲染出来。ReactJS渲染表外的tbody数据
复制链接:http://codepen.io/sumitridhal/pen/wdoZKR?editors=1010
JS
class Table extends React.Component {
constructor() {
console.log('constructor');
super();
this.state = {
data: itemStorage.fetch()
}
console.log(this.state.data);
}
render() {
return (
<tbody role="alert" aria-live="polite" aria-relevant="all">
{this.state.data.map((item, i) => <TableRow key = {i} data = {item} />)}
</tbody>
);
}
}
class TableRow extends React.Component {
render() {
return (
<tr>
<td><span>{this.props.data.username}</span></td>
<td><span>{this.props.data.fullname}</span></td>
<td><span>{this.props.data.point}</span></td>
<td><span>{this.props.data.notes}</span></td>
<td><button className="btn btn-success btn-xs"><i className="fa fa-pencil-square-o"></i></button>
<button className="btn btn-danger btn-xs"><i className="fa fa-trash-o"></i></button>
</td>
</tr>
);
}
}
let tr = $("#table");
React.render(<Table />, tr[0]);
#What实际上是怎么回事?
即使<tr> <td>
标签丢失:
嗨@Amid谢谢你的建议。这个建议正在为我工作。我是新来的反应。你建议使用什么而不是多个'React.render'。任何建议与应用程序的体系结构有关? –
检查我的固定笔的链接。请注意,您的html页面包含一个入口点:'
'。并且所有UI结构都在主要的'App'组件中声明,并被渲染到所提到的入口点。因此,您的应用将如下所示:主要组件相关问题