19 lines
364 B
TypeScript
19 lines
364 B
TypeScript
|
|
import type { SetupContext } from 'vue';
|
||
|
|
import { computed } from 'vue';
|
||
|
|
|
||
|
|
export function useModel(props: any, emits: SetupContext<{
|
||
|
|
'update:modelValue': (val: any) => void
|
||
|
|
}>['emit']) {
|
||
|
|
const vModels = computed({
|
||
|
|
get() {
|
||
|
|
return props.modelValue;
|
||
|
|
},
|
||
|
|
set(val) {
|
||
|
|
emits('update:modelValue', val);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
return {
|
||
|
|
vModels
|
||
|
|
};
|
||
|
|
}
|