标签:one rip new methods assm util pre nts temp
import Vue from ‘vue‘
export default new Vue
<template>
<div id="app">
<button @click="passMsg">传你</button>
<my-parent></my-parent>
</div>
</template>
<script>
import bus from "./util/bus";
import MyParent from "./views/Parent";
export default {
components: {
MyParent
},
methods: {
passMsg() {
bus.$emit("msg", "i am from app");
}
}
};
</script>
<style>
</style>
<template>
<div>
<h2>Child--{{childMsg}}</h2>
</div>
</template>
<script>
import bus from "../util/bus";
export default {
data() {
return {
childMsg: ""
};
},
mounted() {
bus.$on("msg", val => {
this.childMsg = val;
});
}
};
</script>
<style>
</style>
标签:one rip new methods assm util pre nts temp
原文地址:https://www.cnblogs.com/xl4ng/p/12593581.html