小程序里为什么调用js的find方法和数组length都会出现报错?
发布于 5 年前 作者 qli 11406 次浏览 来自 官方Issues
https://developers.weixin.qq.com/s/4gakXqm87Af6  

dataClassify: function () {
    let that = this;
    for (let index = 0; index < that.listData.length; index++) {
      if (that.idNumber.find(that.listData[index].orderId) == null) {
        that.idNumber.push(that.listData[index].orderId);
      }
    }

  }
TypeError: Cannot read property 'length' of undefined
    at ye.dataClassify (checkout.js? [sm]:89)
    at checkout.js? [sm]:80

TypeError: Cannot read property 'length' of undefined
    at ye.dataClassify (checkout.js? [sm]:89)
    at checkout.js? [sm]:80

我试过改过,还是不行

  dataClassify: function () {

    let that = this;

    for (let index = 0; index < that.data.listData.length; index++{

      if (that.data.idNumber.find(that.data.listData[index].orderId== null{

        that.data.idNumber.push(that.data.listData[index].orderId);

      }

    }

  }

1 回复

that.data.list

回到顶部