小程序出现大量脚本错误,应该如何处理?

发布于 7 年前作者 xiulan567021 次浏览最后编辑 7 年前来自 ask

小程序大量出现上图所述错误,代码如下:

/**

  * 页面滚动事件

  */

onPageScroll: function(e) {

let that = this;

const query = wx.createSelectorQuery();

query.select(‘#pad’).boundingClientRect();

query.exec(function(res) {

if (res == null || res.length < 1 || res[0].top == null) {

return;

}

that.setData({

scroll: res[0].top <= 0 ? true : false,

autoPlay: (res[0].top <= 0 ? false : true)

});

})

},

目的是页面滚动的时候,view实现吸顶效果,在开发者工具及真机调试中,都能够正常运行,但是在日志中出现大量如上图提示,这里应该解决呢?

3 回复
naxie
naxie1 楼6 年前

目前我也遇到类似的情况  测试永远没找到问题  但是后台会报一些不可思议的错误;你这个吸顶可以考虑下加个settimeout定时任务  这样来控制性能消耗

guiyingcao
guiyingcao2 楼6 年前

各路神仙帮帮忙

yangxie
yangxie3 楼5 年前

写的吸顶效果 卡顿么?在低端安卓机中