|
使用uniapp + vue3 开发,用微信小程序调试,$refs.xxx 打印为undefined
代码如下: import {
ref,
getCurrentInstance,
onMounted
} from 'vue'
export default {
setup() {
const {
proxy , ctx
} = getCurrentInstance();
onMounted(() => {
console.log(ctx.$refs.commonRef);
})
return {}
}
}
原因: $refs , 在非h5端不支持 图片:bug3.jpg
官网说明:https://uniapp.dcloud.io/tutorial/vue3-api.html#%E5%AE%9E%E4%BE%8B-property 解决方案: 通过另外的方法去获取dom对象或值. 而我的需求是获取值 。 所以换了一个方法,使用v-model来使用 参考如下链接: https://bugshouji.com/mybird/t15243 |
|
|
