Single Select does not sync with given value or v-model
See original GitHub issueOptions are a array of objects and value/v-model is a object. If I change the value the original is not changed. Works for multiple select very well!
https://codepen.io/anon/pen/eRRLPB HTML:
<div id="app">
<h1>Vue Select</h1>
{{ item }}
<v-select :value.sync="item" :options="options"></v-select>
</div>
JS:
Vue.component('v-select', VueSelect.VueSelect)
new Vue({
el: '#app',
data: function () {
return {
item: { label: 'a', value: 1},
options: [
{ label: 'a', value:1},
{ label: 'b', value: 2},
{ label: 'c', value: 3},
{ label: 'd', value: 4},
{ label: 'e', value: 5}
]
}
}
})
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
using v-model on <select> makes first option not appear in ...
When they select an option, I'm using v-model to send that value to the data variable 'name' (will be using this for other...
Read more >What you should know about Vue v-model - LearnVue
Vue v-model is a directive that creates a two-way data binding between a value in our template and a value in our data...
Read more >Form Input Bindings - Vue.js
v -model will ignore the initial value , checked or selected attributes found on any form elements. It will always treat the current...
Read more >Using v-model for Two-Way Binding in Vue.js | DigitalOcean
To bind the value of an input element to a property of your component's data, use v-model="dataProperty" like so.
Read more >Table | Components - BootstrapVue
Internally, the value of the field key specified by the primary-key prop is used as the Vue :key value for each rendered item...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You’re using the latest Vue (2.x) –
.sync
is an old modifier from Vue 1.x. See the docs:The proper way would be to just use the
v-model
directive instead of:value.sync
:https://codepen.io/devmount/pen/jwaBYe
I would recommend to read about the “Form Input Binding” in Vue 2.x in the docs.
@sagalbot Thanks, I preprocessed the submission of my model to convert the object to its value. And that worked. Plus serialization on the sever side of the value into an object, so the value is selected upon load. All good.