1、VmodelTest.vue
<template>
<div @click="$emit('update:modelValue',modelValue+1)">counter:{{ modelValue }}</div>
</template>
<script>
export default {
props: {
modelValue: {
type: Number,
default: 1,
},
},
};
</script>
2、use.vue
<template>
<VmodeTest v-model="count"></VmodeTest>
</template>
<script>
import {
ref,
} from "vue";
export default {
setup() {
const count = ref(1)
return { count };
},
}
};