setData不执行?
发布于 3 年前 作者 li67 6825 次浏览 来自 问答
// onload函数调用此函数
getIdfunction(i,tmpItems){
      if(i == 2return;
      var that = this;

      if(i == 0){
        var tmpArr = [];
        db.collection('video').skip(i*20).get({
          success:function(res{
            for (let j = 0; j < res.data.length; j++) {
              tmpArr.push(res.data[j])
            }
            that.getId(i+1,tmpArr) 
          }
        })
        
      }else {

        var screenHeight = wx.getSystemInfoSync().windowHeight;
        db.collection('video').skip(i*20).get({
          success:function(res{
            var tempItems1 = [];
            for (let j = 0; j < res.data.length; j++) {
              tempItems1.push(res.data[j])
            }
            // 下面setData为什么不执行
            that.setData({ 
              scrollHeight: screenHeight,
              items: tempItems1.length == 20 ? tmpItems.concat(tempItems1) : tempItems1.concat(tmpItems),
              videoUrl:totalItems[0].video,
              
            })
          }
        })
      }
2 回复

原来只要data里数据赋值失败或者说是undefined都会不执行啊

调试?打断点?

回到顶部