Skip to content

Instantly share code, notes, and snippets.

@karlpokus
Created December 8, 2016 10:20
Show Gist options
  • Save karlpokus/08b4ae5cae24e0c1871d758608341889 to your computer and use it in GitHub Desktop.
Save karlpokus/08b4ae5cae24e0c1871d758608341889 to your computer and use it in GitHub Desktop.
vueJS for dummies

Remove item from list

<ul>
  <li v-for="(todo, index) in todos" v-on:click="remove(index)">
    {{ todo.text }}
  </li>
</ul>
var app = new Vue({
  data: {
    todos: [
      {text:'Learn JavaScript'},
      {text:'Learn Vue'}
    ]
  },
  methods: {
    remove: function(index) {
      this.todos.splice(index, 1);
    }
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment