- uniapp
- 写了一个自定义的组件
- 使用uni.createSelectorQuery().in(this). 函数获取dom
- 转小程序没报错
- h5报错 “TypeError: Cannot read property ‘left’ of undefined”
我自己的问题主要出在props的设置里 value 和 default 的问题
下面记录
这里是methods===》
running(num){
const that = this
uni.createSelectorQuery().in(this).selectAll('.nav_item').boundingClientRect(function(res){
that.newLeft = res[num].left + res[num].width/2 - that.lineWidth/2;
that.animation.translateX(that.newLeft).step()
that.animationData = that.animation.export()
}).exec();
}
这里调用===》
this.running(this.activeNum)