Appearance
useVModel
常规实例
TIP
若使用自动按需导入则直接使用useEyVModel,无需导入
外部使用v-model:value时,内部可如下使用即可直接修改copyValue实现父子同步(在 Vue 3.3 之后版本建议使用defineModel)
ts
const props = defineProps({
value: {
type: [String, Number],
default: '',
},
});
const emits = defineEmits<{
'update:value': [value: string | number];
}>();
const copyValue = useVModel(props, 'value', emits);