Subscribe on changes!

[feature request] be able to set onUpdate:modelValue handler with v-model directive

avatar
May 4th 2022

Hello,

What problem does this feature solve?

i would like to find a solution to shorten this syntax :

:modelValue="value" @update:modelValue="handleChange"

i use it everywhere and it's quite long and verbose for what it does,

i would like to be able to set onUpdate:modelValue handler within the v-model directive somehow

What does the proposed API look like?

i would do something like v-model.update="{ value, handleChange }", but i don't really know

thanks !

avatar
May 4th 2022

You can use v-model="value" and give value a computed setter. See Writable Computed.

avatar
May 5th 2022

Well i don't think i will have access to handleChange from a computed property, it comes from vee-validate v-slots

avatar
May 5th 2022

Maybe vee-validate could expose a composable version of the slot-one you are using so you can do:

const modelValue = computed({
  get: () => val.value, // or props.value, depends where it comes from
  set: handleChange,
})

Remember to use the forum or the Discord chat to ask questions!