[Vuejs]-V-Model not cleansed when adding Object to array (Vue-Js)

0👍

The above behaviour is because you are updating the value of same object whenever you add a new todo task.You need to set your object again to add new values as below.

 addToList(value, todos){
    this.todos.push(value);
  this.anotherTodo={ text:'',
done:'false'}
}

Working fiddle here.

0👍

I post this as an answer, but if someone has a better way to do it, I’m all hear.

I solved the way by adding a watch on my list. When the list changes, I clean the model object that’s added to it.

In my production work, I had to add a computed property, since I can’t add a watch on an object’s property, then a watch on said computed property :

watch:{
    todos(){
        this.anotherTodo={};
    },

fiddle as demo

Leave a comment