vue3获取dom节点方法
vue3ref获取dom节点
·
<van-field ref="portNum"/>
<div v-for="(item, index) in 4" :key="index" >
<van-field :ref="(el) => setrefsFun(el, index)"/>
</div>
<script>
setup() {
//1、单个ref
let portNum = ref(null)
return {
portNum,
}
//2、获取多个ref refBtns就是循环的节点
let refBtns = reactive({})
const setrefsFun = (el, item) => {
if (el) {
refBtns[item] = el
}
}
return {
portNum,
setrefsFun,
}
</script>
更多推荐
已为社区贡献3条内容
所有评论(0)