看这里,你在render函数中获取的items变量取自props中的items,在父组件中,你应该没有传过来这个属性,所以他的值为undefined,然后运行map函数出错。 这里你应该是想使用state中的items吧,不然你componentDidMount中的代码没什么意义。 let items = this.state.items
看这里,你在render函数中获取的items变量取自props中的items,在父组件中,你应该没有传过来这个属性,所以他的值为undefined,然后运行map函数出错。
这里你应该是想使用state中的items吧,不然你componentDidMount中的代码没什么意义。