请教,这是小程序的bug?还是我写法有问题?
事件lockBtnTap()执行,wx.createSelectorQuery()计算元素节点宽度这段代码有时候执行到,有时候没执行到;看打印的log,执行的时候打印出来是这样
,不执行的时候是
(我给它断点的时候才100%执行到,去掉断点就执行不到了)
lockBtnTap(event){ this.setData({ lockDialogBoll: true, curLockName: event.currentTarget.dataset.name }); console.log('laiba') //计算弹窗滑动开门盒子 var _this = this; wx.createSelectorQuery().selectAll('.slideBox').boundingClientRect(function (rects) { rects.forEach(function (rect) { // rect.id // 节点的ID // rect.dataset // 节点的dataset // rect.left // 节点的左边界坐标 // rect.right // 节点的右边界坐标 // rect.top // 节点的上边界坐标 // rect.bottom // 节点的下边界坐标 // rect.width // 节点的宽度 // rect.height // 节点的高度 _this.setData({ slideBoxWidth: rect.width }) console.log('slideBoxWidth:'+rect.width); }) }).exec() wx.createSelectorQuery().selectAll('.slide').boundingClientRect(function (rects) { rects.forEach(function (rect) { _this.setData({ slideWidth: rect.width }) console.log('slideWidth:' + rect.width); }) }).exec() } |
