Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to dynamically add or remove items from a list in Vue.js ?

  • Last Updated : 19 Feb, 2021

Vue is a progressive framework for building user interfaces. The core library is focused on the view layer only and is easy to pick up and integrate with other libraries. Vue is also perfectly capable of powering sophisticated Single-Page Applications in combination with modern tooling and supporting libraries. 

Using Vue.js one can easily add or remove items in a list dynamically using the v-model directive. This directive binds all the possibilities to a single channel. When the user selects an option from the list of available ones, it adds it to the list of values. Similarly, if the user deselects any option, it removes it from the list of values.



    <script src=
    <div id='parent'>
      <h1 style="color: green;">
          <p><strong>Favourite Sports:</strong>
        <input type="checkbox" id="cricket" 
               value="cricket" v-model="sports">
        <label for="cricket">Cricket</label>
        <input type="checkbox" id="football" 
               value="football" v-model="sports">
        <label for="football">Football</label>
        <input type="checkbox" id="hockey" 
               value="hockey" v-model="sports">
        <label for="hockey">Hockey</label>
        <input type="checkbox" id="badminton"
               value="badminton" v-model="sports">
        <label for="badminton">Badminton</label>
        <input type="checkbox" id="arching" 
               value="arching" v-model="sports">
        <label for="arching">Arching</label>
        <p><strong>Sports You  Like:</strong>
          {{ sports }}
    <script src='app.js'></script>


const parent = new Vue({
    el : '#parent',
    data : {
        sports : []


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!