jeudi 15 juillet 2021

add checkboxs values to data array in nuxt

im using nuxt 2.15

this is my checkboxs :

<div v-for="category in categories" v-bind:key="category.id" class="ml-4">
  <input type="checkbox" name="categories[]" @change="search()" v-model="form.categories" :id="`category`+category.id" :value="category.id">
  <label :for="`category`+category.id"></label>
</div>

when i check one of them , form.categories get true value ! the value of checkbox not add to form.categories array

it should store values of checkboxes (category.id) in form.categories but instead it toggle form.categories to true and false state !!!!

how can i store checkbox values inside form.categories ?

p.s : i have a project with older version of nuxt and its working fine ! but in new project its not working ! is it because of newer version ?

tnx




Aucun commentaire:

Enregistrer un commentaire