<template>
    <div>
    <div>孙子组件:{{ dd}}</div>
    <el-button type="primary" @click="fun2">主要按钮</el-button>
    <el-button type="primary" @click="add">$parent获取父组件的</el-button>   
   </div>
</template>
   
   <script>
   import event from '@/views/test/event.js'
   export default {
    name: 'son',
    data() {
     return {
      index: 1,
      dd:'',
      str:'我是兄弟1传过来的值',
      f:'父组件通过$refs取我的值'
     }
    },
    mounted(){
        event.$on("dd", (e) => {
           this.dd = e.str
       })
     
    },
    methods:{
        fun2(){
            event.$emit('child',this.str)
        },
        add(){
            console.log("我是子组件")
             console.log(this.$parent.msg)
             this.$parent.parentEvent();
        },
        
    }
   }
   </script>
   