Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/439.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript this.state.cartIsh.map不是函数_Javascript_Reactjs - Fatal编程技术网

Javascript this.state.cartIsh.map不是函数

Javascript this.state.cartIsh.map不是函数,javascript,reactjs,Javascript,Reactjs,浏览器说我的“this.state.cartIsh.map”不是一个函数。下面是我的代码。(顺便说一句,我使用的是在线代码编辑器。) 类应用程序扩展了React.Component{ 建造师(道具){ 超级(道具); 此.state={ 卡蒂什:[], } } render(){ 返回( {this.state.cartIsh.map((项)=>{ 返回( {item.ID} {item.Quantity},{item.Name} ); })} ); } } console.log(type

浏览器说我的“this.state.cartIsh.map”不是一个函数。下面是我的代码。(顺便说一句,我使用的是在线代码编辑器。)

类应用程序扩展了React.Component{
建造师(道具){
超级(道具);
此.state={
卡蒂什:[],
}
}
render(){
返回(
{this.state.cartIsh.map((项)=>{
返回(
{item.ID}
{item.Quantity},{item.Name}
);
})}
);
}
}


console.log(typeof this.state.cartIsh)在
return
之前是什么意思呢?你用什么浏览器?我在Codesandbox中试过你的代码,它对空数组
cartIsh
和非空数组都很好。我不知道出了什么问题。我用的是谷歌浏览器。我现在切换到stackblitz,代码运行良好。谢谢。
console.log(typeof this.state.cartIsh)
return
之前是什么意思?你用什么浏览器?我在Codesandbox中试过你的代码,空数组
cartIsh
和非空数组都很好。我不知道出了什么问题。我用的是谷歌浏览器。我现在切换到stackblitz,代码运行良好。谢谢