setData不执行?

发布于 5 年前作者 li677106 次浏览最后编辑 5 年前来自 ask
// 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 回复
kpan
kpan1 楼5 年前

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

huangping
huangping2 楼7 个月前

调试?打断点?