使用 react 和 express 以 JSON 格式获取和存储。如何正确引用名称中包含百分号的表?
componentDidMount() {
// Get data and sort it by ID, then add it to state
fetch('http://localhost:5000/citystats')
.then((data) => data.json())
.then((data) => this.setState( { stats: data } ));
}
// Table etc
{this.state.stats.map( (item) => {
<td>{item.POP%}</td>
}
最佳答案
使用方括号表示法:
<td>{item["POP%"]}</td>
关于javascript - 获取数据时如何处理表名中的百分号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56031926/