defineExpose方法:方法在子,触发在父
父:
<template>
<CustomDivider content-position="left" :borderLeft="false"
>客户干系人<template #right>
<el-button
size="small"
type="primary"
link
@click="custContactorRef.createNew()"
v-if="editAuth"
>新增</el-button
>
</template>
</CustomDivider>
<CustomerContactor
ref="custContactorRef"
:bscSerial="clueData.Chance.BscSerial"
:formSn="clueData.Chance.FormSn"
:bscFollowers="clueData.Normal.Stakeholders"
:editStatus="editAuth"
@popData="val => (clueData.Normal.Stakeholders = val)"
/>
</template>
子:
<script setup lang="ts">
const createNew = () => {
dialogVis.value = true;
};
defineExpose({ createNew });
</script>
<template>
<div>
<el-dialog
v-model="dialogVis"
width="800px"
title="客户干系人"
align-center
:close-on-click-modal="false"
>
<CustomerTableList
:companyCode="companyCode"
:disabledValues="list.map(el => el.Name)"
@selectHandle="onSelect"
@close="dialogVis = false"
/>
</el-dialog>
</div>
</template>