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

fix(runtime-dom): v-model.number work with select tag #2254

Closed
wants to merge 9 commits into from
Closed

fix(runtime-dom): v-model.number work with select tag #2254

wants to merge 9 commits into from

Conversation

edison1105
Copy link
Member

@edison1105 edison1105 commented Sep 28, 2020

fix #2252

@edison1105 edison1105 changed the title fix(runtime-dom): vModel with modifiers should work with select fix(runtime-dom): v-model.number work with select tag Sep 28, 2020
Comment on lines +176 to +180
let domValue: string | number = el.multiple ? selectedVal : selectedVal[0]

if (castToNumber) {
domValue = toNumber(domValue)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edison1105, I would suggest handling the case of multiple select here.
When the el.multiple is true, domValue will be assigned with an array from selectedVal.
The domValue = toNumber(domValue) will cast an array of numbers to number.

This will make the multiple select case throw an error of:

<select multiple v-model> expects an Array or Set value for its binding, but got Number.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks~ @69hunter. I will update this.

@edison1105
Copy link
Member Author

closed this PR, because the repo of this PR is deleted.😂😂😂.
so I open a new PR #2308

@edison1105 edison1105 closed this Oct 6, 2020
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

Successfully merging this pull request may close these issues.

v-model.number does not work for select tag
2 participants