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

Why not automatically convert the input number type to [number] #12914

Closed
wbxl2000 opened this issue Dec 29, 2022 · 3 comments
Closed

Why not automatically convert the input number type to [number] #12914

wbxl2000 opened this issue Dec 29, 2022 · 3 comments

Comments

@wbxl2000
Copy link

wbxl2000 commented Dec 29, 2022

What problem does this feature solve?

Under Vue 2.x, I found that I should use 'Modifiers' when I wanna input a number and get a v-model value. But in Vue 3.x, it is automatically convert the input number type to [number] but [string] without Modifiers. So I doubt there are some reasons for it, what are they?

What does the proposed API look like?

<input type="number" v-model="count">
when input something, count will be type [number] always but [string]

@posva
Copy link
Member

posva commented Dec 29, 2022

IIRC, after being discussed in an issue in Vuejs/core, it just made more sense. However, changing it in v2 would potentially break a lot of people’s code relying on this behavior

@dev-myatminsoe
Copy link

Is there anyway to remove that auto casting? If we want to get as numeric value we can always use v-model.number but if we want to get the string value, now there's no way.

Why would we want a string value with input type number?

  1. I want the leading zeros.
  2. Display appropriate inputs. (I can use inputmode but input type number is the only way to show a keyboard with enter(return) key on mobile safari)

@brandonburkett
Copy link

@dev-myatminsoe did you figure out a way to opt out of the auto casting?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants