【发布时间】:2019-08-20 20:11:27
【问题描述】:
我正在尝试在 reactjs 准备一个 restfulpi。但是因为我是reactjs新手,英文也不是很流利,所以遇到了一个问题。我的应用程序的目的是列出出版商的书籍。您可以从下面访问我的代码和错误。如果你帮助我,我可以做到。谢谢。
错误:
第 21 行:应为赋值或函数调用,但看到的是表达式 no-unused-expressions
我的代码:
`` `
class App extends Component {
state = {
books:[]
}
componentWillMount(){
axios.get('http://localhost:3000/books').then(( response)=>{
this.setState({
books: response.data
})
});
}``
`` `
render() {
let books = this.state.books.map((book) =>
{
return
(
<tr key={book.id}>
<td>{book.id}</td>
<td>{book.title}</td>
<td>{book.rating}</td>
<td>
<Button color="success" size="sm" className="mr-2">Edit </Button>
<Button color="danger" size="sm">Sil</Button>
</td>
</tr>
)
});``
`` `
return (
<div className="App container">
<h1>Book List</h1><br></br>
<Table>
<thead>
<tr>
<th>#</th>
<th>Title</th>
<th>Rating</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{books}
</tbody>
</Table>
</div>
);``
【问题讨论】:
-
第 21 行到底是哪一行?
标签: javascript reactjs frontend