当我使用 SuperAgent 时我没有这个问题,但是我决定使用 Window.fetch polifyl 并且我遇到了这个问题。我看到所有数据都已加载,但仍然显示错误。
你能帮我找出这个错误吗:
在 render() 中,我根据获得的列表生成一个组件列表:
render() {
if (this.state.data.list) {
console.log("render: " + this.state.data.list);
var counter = 0;
const list = this.state.data.list.map((item) => {
....
最佳答案
屏幕截图中的 promise 处理程序将不起作用:
.then((json) => console.log('parsed json: ', json))
.then((json) => { this.setState({ data: json }); })
“从解决这个 promise 中获取值并将其传递给
console.log
。然后,获取 console.log 的返回值(即 undefined
)并将其传递给 this.setState
。”关于json - react + 获取 + Json。类型错误 : Cannot read property of undefined,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42033051/