changeCata 里面item不存在

来源:3-2 菜品信息

稻鹰

2019-03-18 17:18

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)){

            //不用加载数据

          this.setState({currentlist:this.state.foodlist.filter(item=>item.pid==selectCata.id)})    

        }else{

            //需要加载数据

         this.setState({foodlist:this.state.foodlist.concat(this.getData(selectCata))},()=>{

             this.setState({currentlist:this.state.foodlist.filter(item=>item.pid==selectCata.id)}) 

         }) ;

        }

    }


写回答 关注

0回答

还没有人回答问题,可以看看其他问题

Taro多端框架开发外卖首页

Taro 一套代码多端运行的框架,带你掌握Taro开发基本语法,以及项目开发

22910 学习 · 82 问题

查看课程

相似问题