-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
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
Vue Selected Bind Does Not Work on Option Tags #8016
Comments
|
I humbly ask that you reconsider this issue. You are 100% correct about Regardless, thank you for your hard work on an excellent product. |
It is indeed useful for SSR but I haven't checked if it's not added yet |
I'm running into a similar issue on a select box where I can't use v-model. Is there a workaround or fix for this issue? |
One workaround is to create a directive (named Vue.directive('attr', (el, binding) => {
// Boolean attributes take the empty string as a `true` value
if (binding.value === true) binding.value = ''
if (binding.value === '' || binding.value) {
el.setAttribute(binding.arg, binding.value)
}
}) Then use it in your template like <option v-attr:selected="location === 'all'"> |
Version
2.5.16
Reproduction link
https://codepen.io/jbenner/pen/geJqex
Steps to reproduce
data
property namedlocations
which is an array consisting of['all', 'north', 'south', 'east', 'west']
.option
tag like so<option v-for="location in locations" :selected="location === 'all'">{{ location }}</option>
.What is expected?
The
selected
attribute to be set on the "all"option
element.What is actually happening?
The
selected
attribute is not being set.I've also tried the following while attempting to debug but to no avail:
The text was updated successfully, but these errors were encountered: