<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>    

Logo

前往低代码交流专区

更多推荐