v-model.number modifier doesn't work on custom component
Version
3.0.0
Reproduction link
https://codepen.io/gilian1993/pen/XWKWjZY?editors=1111
Steps to reproduce
1: Open codepen link 2: Add a number to the fisrt input and the type "number" will display. This is a normal input. 3. Add a number to the second input and the type "string" will display. This is a custom input.
What is expected?
The custom input should return a number.
What is actually happening?
It returns a string.
you can get the value of modelModifiers
as prop, and turn value into number inside the component.
a bad example:
app.component('custom-input', {
props: ["modelValue", "modelModifiers"],
template: `<input :value="modelValue" @input="$emit('update:modelValue', modelModifiers.number ? Number($event.target.value) : $event.target.value)"/>
`
})
This should be related to https://github.com/vuejs/vue-next/issues/1825
you can get the value of
modelModifiers
as prop, and turn value into number inside the component.a bad example:
app.component('custom-input', { props: ["modelValue", "modelModifiers"], template: `<input :value="modelValue" @input="$emit('update:modelValue', modelModifiers.number ? Number($event.target.value) : $event.target.value)"/> ` })
This does work, however this is more like a workaround I hope?