***vue 3.3 新特性
defineModel的使用
子组件
<template>
<input v-model="data" />
<input v-model="data1" />
</template>
<script setup>
import { ref,defineModel } from 'vue'
const data=defineModel()
const data1 = defineModel('test')
</script>
父组件
<template>
<ComponentName v-model="data" v-model:test="data1" />
</template>
<script setup>
import { ref } from 'vue'
import ComponentName from "./ComponentName.vue"
const data = ref('test')
const data1 = ref('test1')
</script>
评论区