todoList() {return this.state.todos.map(function(element,i){ return <div todo={element} key = {i}>; <tr> <td>{element.todo_description}</td> <td>{element.todo_responsible}</td> <td>{element.todo_priority}</td> <td> <Link to={"/edit/"+element._id}>Edit</Link> </td></tr></div>})}render(){ return( <div> <h2>To Do List</h2> <table className="table table-striped" style={{ marginTop: 20 }}> <thead> <tr> <th>Description</th> <th>Responsible</th> <th>Priority</th> <th>Action</th> </tr> </thead> <tbody> {this.todoList()} </tbody> </table> </div> )}}export default toDosList;
2 回答
慕娘9325324
TA贡献1783条经验 获得超4个赞
tr 标签是 table 标签的子标签,所以你应该在 div 之后添加一个 table 标签,如下所示:
<div todo={element} key = {i}>;
<table>
<tr>
<td>{element.todo_description}</td>
<td>{element.todo_responsible}</td>
<td>{element.todo_priority}</td>
<td>
<Link to={"/edit/"+element._id}>Edit</Link>
</td>
</tr>
</table>
</div>
忽然笑
TA贡献1806条经验 获得超5个赞
像这样包装你:
<table>
<tbody>
<tr>
<td>{element.todo_description}</td>
<td>{element.todo_responsible}</td>
<td>{element.todo_priority}</td>
<td>
<Link to={`/edit/${element._id}`}>Edit</Link>
</td>
</tr>
</tbody>
</table>
添加回答
举报
0/150
提交
取消