因为VUE3中使用setup没有this作用域,所以报错
解决办法:使用getCurrentInstance()方法获取组件实例
- import { getCurrentInstance } from 'vue';
-
- const instance = getCurrentInstance(); // 获取组件实例
- const DOMArr = uni.createSelectorQuery().in(instance);
- DOMArr.select('.posterMake')
- .boundingClientRect(poster => {
- posterX.value = poster.left;
- })
- .exec();
