how to implement v-for checkbox list
-
Hi,
I need to loop through an array of values in a form to create a checkbox list and submit the selected checkbox value. my code is below :<tr v-for="(item,index) in MenuList">
<label>{{item.menu_name}}
<q-checkbox v-model=“vchecklist[index]” ></q-checkbox>
</label>
</tr>this is not working . i select one checkbox but selected another one .
my form design is attached as image :
-
menuList
should be{ menu_name: 'blabla label', model: false }
<tr v-for="(item,index) in MenuList"> <label> {{item.menu_name}} <q-checkbox v-model=“item.model”></q-checkbox> </label> </tr>
This is one option. There are others too. Just don’t bind v-model to a numeric index in an array. Use object instead.
-
@rstoenescu thanks a lot :).