[Vuejs]-How to push new values into array when checkbox is checked and remove when unchecked using Vue.js?

0๐Ÿ‘

โœ…

    <ul class="category__list">
      <li v-for="(category, index) in categoriesData[categoryTitle]" :key="index">
        <input type="checkbox" :value="category" v-model="selectedCategories"> 
               {{category}}
      </li>
   </ul>

If you use v-model on checkbox input and declare it as array Vue will automaticly do the job for you.
SelectedCategories array will be checked boxes.

Leave a comment