[Vuejs]-Adding an object to a parent array

0👍

Change your code:

addTodo (toDo) {
  this.todos.push(toDo)
}

Because the data you pass from the child component itself is an Object, so you don’t need to use the {} symbol anymore.

0👍

If I am seeing everything correctly, the problem is that the emit is firing on the child node and not being caught in the parent. Try this

this.$parent.$emit('add-todo', {
        title: title,
        project: project,
        done: false
      })

In this yours was this.$emit, I am proposing this.$parent.$emit

Leave a comment