Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v-model.number modifier doesn't work on custom component #2326

Closed
lian-ders opened this issue Oct 7, 2020 · 4 comments
Closed

v-model.number modifier doesn't work on custom component #2326

lian-ders opened this issue Oct 7, 2020 · 4 comments

Comments

@lian-ders
Copy link

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.

@unbyte
Copy link
Contributor

unbyte commented Oct 7, 2020

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)"/>
`
})

@69hunter
Copy link
Contributor

69hunter commented Oct 7, 2020

This should be related to #1825

@lian-ders
Copy link
Author

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?

@canbulgay
Copy link

git

Dude just change this syntax

@github-actions github-actions bot locked and limited conversation to collaborators Sep 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants