diff --git a/section-code/src/components/UserEdit.vue b/section-code/src/components/UserEdit.vue index f2defed..028b325 100644 --- a/section-code/src/components/UserEdit.vue +++ b/section-code/src/components/UserEdit.vue @@ -13,7 +13,8 @@ methods: { editAge(){ this.userAge = 30; - eventBus.$emit('ageWasEdited', this.userAge) + // eventBus.$emit('ageWasEdited', this.userAge) + eventBus.changeAge(this.userAge); } } } diff --git a/section-code/src/main.js b/section-code/src/main.js index e6e6ea3..565f120 100644 --- a/section-code/src/main.js +++ b/section-code/src/main.js @@ -1,7 +1,13 @@ import Vue from 'vue' import App from './App.vue' -export const eventBus = new Vue(); +export const eventBus = new Vue({ + methods:{ + changeAge(age){ + this.$emit('ageWasEdited', age) + } + } +}); new Vue({ el: '#app',