1
0
forked from test/crm

fix: also handle value+change along with v-model

This commit is contained in:
Shariq Ansari 2023-11-13 18:13:04 +05:30
parent 7bd276c37b
commit 21cc553d0c

View File

@ -31,13 +31,18 @@ const props = defineProps({
},
})
const emit = defineEmits(['update:modelValue'])
const emit = defineEmits(['update:modelValue', 'change'])
const attrs = useAttrs()
const valuePropPassed = computed(() => 'value' in attrs)
const value = computed({
get: () => props.modelValue,
set: (val) => emit('update:modelValue', val?.value),
get: () => (valuePropPassed.value ? attrs.value : props.modelValue),
set: (val) => {
debugger
return emit(valuePropPassed.value ? 'change' : 'update:modelValue', val?.value)
}
})
const autocomplete = ref(null)