1、在孙组件里定义事件,通过$emit把值传出去
孙组件:planPop.vue
<template slot="action" slot-scope="record">
<span @click="handleDetail(record)" class="detailBtn">查看</span>
</template>
// 点击查看
handleDetail(record) {
this.$emit('showPlanImg', true);
this.$emit('getPlanId', record.id);
},
子组件:siteSearch.vue
<plan-pop ref="plan" :manufactorList="manufactorList" :siteTypeList="siteTypeList" :deviceTypeList="deviceTypeList" @moveToSitePlan="moveToSitePlan" v-on="$listeners"></plan-pop>
3、父组件通过传过来的自定义事件,获取孙组件的值
父组件:index.vue
<site-search ref="siteSearch" :showLeft="showLeft" :regionList="regionList" :siteTypeList="siteTypeList" @siteNumChange="siteNumChange" @moveToSite="moveToSite" @getType="getType" @showPlanImg="showPlanImg" @getPlanId="getPlanId" />
// 显示巡检的图裂和开关
showPlanImg(data) {
this.isShowPlanImg = data;
},
// 获取巡检计划弹窗点击查看传回来的巡检id
getPlanId(id) {
this.planId = id;
},