Closed
Description
Clear and concise description of the problem
We want to upgrade to defineModel. useVModel syntax needs to adjust to this
const props = withDefaults(defineProps<{modelValue?: string}>(), {modelValue: '123'})
const emit = defineEmits<{ 'update:modelValue': [string]}>()
const modelVal = useVModel(props, 'modelValue', emit, {passive: true})
=>
const modelVal = defineModel<string>({default: '123'})
There shouldn't be any unexpected breaking changes. I'm pretty sure the two should behave identically
Lastly, I believe this can adjust the workflow for BFormInput. We can explicitly define the modifiers, and create more straightforward syntax for modifiers. https://vuejs.org/api/sfc-script-setup.html#modifiers-and-transformers
const [modelValue, modelModifiers] = defineModel<string, 'trim' | 'number'>({
// get() omitted as it is not needed here
set(value) {
// if the .trim modifier is used, return trimmed value
if (modelModifiers.trim) {
return value.trim()
}
if(modelModifiers.number) {
//
}
// otherwise, return the value as-is
return value
}
})
etc etc