File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 4
4
</footer >
5
5
</template >
6
6
<script >
7
+ // imports
8
+ import { bus } from ' ../main' ;
9
+
7
10
export default {
8
11
props: {
9
12
title: {
@@ -15,6 +18,11 @@ export default {
15
18
return {
16
19
17
20
}
21
+ },
22
+ created (){
23
+ bus .$on (' titleChanged' , (data ) => {
24
+ this .title = data;
25
+ });
18
26
}
19
27
}
20
28
</script >
Original file line number Diff line number Diff line change 4
4
</header >
5
5
</template >
6
6
<script >
7
+ // imports
8
+ import { bus } from ' ../main' ;
9
+
7
10
export default {
8
11
props: {
9
12
title: {
@@ -18,7 +21,9 @@ export default {
18
21
},
19
22
methods: {
20
23
changeTitle : function (){
21
- this .$emit (' changeTitle' , ' Vue Ninjas' );
24
+ // this.$emit('changeTitle', 'Vue Ninjas');
25
+ this .title = ' Vue Ninjas' ;
26
+ bus .$emit (' titleChanged' , ' Vue Ninjas' );
22
27
}
23
28
}
24
29
}
Original file line number Diff line number Diff line change 1
1
import Vue from 'vue'
2
2
import App from './App.vue'
3
3
4
+ export const bus = new Vue ( ) ;
5
+
4
6
new Vue ( {
5
7
el : '#app' ,
6
8
render : h => h ( App )
You can’t perform that action at this time.
0 commit comments