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'組件中聲明,並被渲染到所提到的入口點。因此,您的應用將如下所示:主要組件相關問題