微信小程序-加载更多和下拉数据使用连接concat出现Cannot read property 'concat' of undefined,(解决)

出现这个问题是因为使用concat这个函数的对象,没有定义,就是需要连接的上一页的数据 和当前的数据变量,没有定义。

例如:

 dataFormat: function (d) {
    if (d.data.status == "1") {
      if (d.data.pro) {
        var datas = this.data.data.concat(d.data.pro), flag = d.data.pro.length < 4;//如果小于4,肯定加载完了,否则不确定
        this.setData({
          data: datas,
          disabled: flag ? true : false,
          moreTxt: flag ? "已加载全部数据" : "点击加载更多",
          hasMore: true,
          dataNull: true
        });

      } else {
        this.setData({
          hasMore: false,
          dataNull: false
        });
      }
    } else {
      console.log('接口异常!')
    }
    wx.hideToast();
  },
这里就是需要定义一下,datas才能用。不信试试

猜你喜欢

转载自blog.csdn.net/qq_33182756/article/details/80141966