-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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 does not work for radio buttons #10886
Comments
I believe the It seems relatively easy to work around this problem. I wonder whether it's worth the extra bytes to support it. That said, if it isn't supported that should probably be documented somewhere. |
Yes, in the source code of the |
From the docs it says: I think it means strings that are being typed into an input or text box. With the radio button you are not inputing any text. You are just changing the state of the radio button from checked to unchecked. And you have an attribute with the name value, which will always be in string. The value attribute is just a way to identify or describe the state of the radio button depending on the context. So, if I want to use on and off, or true and false, these are just descriptive values. Perhaps, a workaround is to bind the value attribute to a constant variable of number type. Or an object can be used in this case:
|
我认为 @neneodonkor 说的很对,所以,我觉得这个问题严格来说不算是一个问题,如果想对 所以我认为正因如此,Vue官方才只对 |
@YiMo1 感謝 |
Vue version
3.4.25
Link to minimal reproduction
https://play.vuejs.org/#eNqVkk1LAzEQhv9KyKUKdZeqp7ItqPSgBxX1mMu6nW1T80U+amXZ/+5MamsPsuAlZN73yfDOkI7fOFdsE/Apr0LjpYssQExuLozUzvrIOuahZT1rvdVshOhIGGEaa0JkEfCYEXB2LkxV7jvgWywiaKfqCFgxVq0n867b833P6PrlwLYHpSoRyKA0LmFjdGeC+3opreBsW6tE9YTuF9ouQRUm6XfwKFIL1E2tCfmpSgoRh7td/qtbVZ5MxMc8BtxBK1fFJliD6+sovuCN1U4q8E8uStyR4FOWHfJqpeznQ9aiTzA+6M0amo8/9E3YkSb4s4cAfguCH71Y+xVgNrIXr4+ww/vRxJmSQnrAfIFgVaKMe+w2mSXGPuFy2vv8CaRZvYXFLoIJh6EoKJF95gXHj3E3MPpv3KviOr8Tpuf9N4sK1cE=
Steps to reproduce
ref()
and bind the radio buttons withv-model.number
to itWhat is expected?
The value of the
ref
should be of typenumber
.What is actually happening?
It is always of type
string
(tested in Chrome and Firefox.)System Info
No response
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: