
Learning Vue.js 2
By :

When we were rewriting the shopping list application using simple components, we lost the application's functionality. The exercise suggests using an events emitting system in order to bring the functionality back.
The code we ended up with in this section was looking similar to what is in the chapter3/vue-shopping-list-simple-components folder.
Why doesn't it work? Check the devtools error console. It states the following:
[Vue warn]: Property or method "addItem" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option. (found in component <add-item-component>)
Aha! This happens because inside add-item-template
we are calling the addItem
method which does not belong to this component. This method belongs to the parent component, and of course, the child component does not have access to it. What should we do? Let's emit events! We already know how to...