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">
    <q-checkbox v-model=“vchecklist[index]” ></q-checkbox>

    this is not working . i select one checkbox but selected another one .

    my form design is attached as image :


  • Admin

    menuList should be { menu_name: 'blabla label', model: false }

    <tr v-for="(item,index) in MenuList">
          <q-checkbox v-model=“item.model”></q-checkbox>

    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 :).

Log in to reply