V-model绑定一个遍历对象写法

331 阅读1分钟

报错信息:'v-model' directives cannot update the iteration variable 'item' itself.

若写v-model:modelItem = "item"报错,改写成v-model:modelItem = "arr[index]"格式即可

<A
    v-for="(item, index) in arr"
    :key="`fourthly-${index}`"
    v-model:modelItem = "arr[index]"
  ></A>
  
  <script setup>
      const arr = ref([])
  </script>