在网上看了很多篇文章,全都是复制粘贴,根本用不了,然后还是用了这个方式解决
template代码块如下
<div class="customer-box" ref="customer">
setup如下
import { ref, watchEffect } from 'vue';
let customer = ref(null)
watchEffect(() => {
console.log(customer.value)
})
如果还是获取不到
const { proxy } = getCurrentInstance()
const customer = proxy.$refs['customer']
conso.log(customer)