Reputation: 6978
Basically, I want to repeat q-select/q-tree for each item in the list:
<q-item v-for="item in list">
{{item}}
<q-select
v-model="selected_val"
radio
:options="option"
/>
</q-item>
In data section, I have following code
data(){
return{
list:['item1','item2','item3'],
option:[
{label:'first',value:'first'},
{label:'second',value:'second'},
{label:'third',value:'third'}
],
selected_val:''
}
The current result shown will reflect the value of each item.
i'm using quasar framework with Vue js.
Upvotes: 0
Views: 4653
Reputation: 1856
Your selected_val model data should not be a string, but an array.
new Vue({
el: '#q-app',
data(){
return {
list:['item1','item2','item3'],
selected_val: [],
options: [
{label:'first',value:'first'},
{label:'second',value:'second'},
{label:'third',value:'third'}
]
}
}
})
<div id="q-app">
<q-item v-for="(item, index) in list">
<q-item-side>{{item}} </q-item-side>
<q-item-main>
<q-select v-model="selected_val[item]" radio :options="options" />
</q-item-main>
</q-item>
<q-list>
<q-item v-for="item in list"> {{item}} selected value: {{selected_val[item]}}</q-item>
</div>
See codepen for demonstration
Upvotes: 1
Reputation: 51
This is because you are using same v-modal for all the q-select. Each q-select needs to have unique v-modal.
You can achieve this by creating a similar array as list and adding it to v-modal
Upvotes: 0