详解vue 组件之间使用eventbus传值

2020-06-16 05:53:00易采站长站整理

}
},
components: {
value,
click,
my_plug_in,
sendparent,
testmintui,
transimissionone,
transimissiontwo,

},
methods: {
getmessagefromchild: function(data) {
console.log(data);
}
}
}
</script>

<style>
body {
background-color: #f8f8ff;
font-family: 'Avenir', Helvetica, Arial, sans-serif;
color: #2c3e50;
}

ul {
width: 12rem;
}

ul li {
list-style: none;
}

ul li:not(:last-child) {
list-style: none;
width: 2rem;
margin-left: 0.1rem;
margin-right: 0.1rem;
float: left;
text-align: center;
background: #2C3E50;
color: white;
}

ul li a {
text-decoration: none;
font-size: 16px;
color: white;
line-height: 1rem;
text-align: center;
}

ul li:nth-child {
list-style: none;
clear: both;
}

.choose_div {
width: 100%;
overflow: scroll;
}
</style>

请无视掉没用的代码。接着就是定义eventbus了


window.eventBus = new Vue();

就这样,很是简单,当然,对于级别的可以使用prop,下回再讲