changeCata 里面item不存在
food.js?58d1:34 Uncaught TypeError: Cannot read property 'pid' of undefined
? ? at eval (food.js?58d1:34)
? ? at Array.filter (<anonymous>)
? ? at Food.eval (food.js?58d1:34)
? ? at Food.clearCallBacks (index.js?36eb:1754)
? ? at updateComponent (index.js?36eb:1665)
? ? at rerender (index.js?36eb:1700)
changeCata(selectCata){
????????this.setState({selectCata:selectCata});
????????if(this.state.foodlist.some(item=>item.pid==selectCata.id)){
????????????//不用加載數(shù)據(jù)
???????? ?this.setState({currentlist:this.state.foodlist.filter(item=>item.pid==selectCata.id)})????
????????}else{
????????????//需要加載數(shù)據(jù)
???????? this.setState({foodlist:this.state.foodlist.concat(this.getData(selectCata))},()=>{
???????? ??? this.setState({currentlist:this.state.foodlist.filter(item=>item.pid==selectCata.id)})?
???????? }) ;
????????}
????}
2019-03-21
打斷點(diǎn),看看你的foodlist的值是什么,還有看看有沒(méi)有拼寫(xiě)錯(cuò)誤foodlist,我一般都用的是駝峰寫(xiě)法