(子组件数据传输给父组件:子组件需要利用一个$emit(‘声明的事件’,‘需要发送的值’);而父组件的接收需要利用事件进行接收–也就是在子组件中进行事件的绑定,在父组件的methos中,接收的函数需要有一个参数,这个参数也就是子组件传给父组件之间的值。)
<body>
<div id="app">
<Father></Father>
</div>
<template id="father">
<div>
<div>父组件</div>
<p>获取到了 {
{ msg2 }} </p>
(5.)定义自定义事件
<Son @getmsg='getmsg'></Son>
</div>
</template>
<template id="son">
<div>
(3.)发送数据事件驱动
<button @click="givefathermsg"> give </button>
<div>子组件</div>
</div>
</template>
___________________________________________________________________________
Vue.component('Father', {
template: "#father",
(2.)定义需要接收的数据
data() {
ret