父组件
<template>
<div class="">
<el-button type="text" @click="openSurvey">点击打开 Dialog</el-button>
<survey ref="survey"></survey>
</div>
</template>
<script>
import survey from './survey.vue'
export default {
components: {
survey
},
methods:{
openSurvey(){
this.$refs.survey.init()
}
}
}
</script>
子组件
<template>
<el-dialog title="" :visible.sync="dialogVisible" append-to-body>
<div>弹窗内容</div>
</el-dialog>
</template>
<script>
export default {
data() {
return {
dialogVisible: false,
};
},
methods: {
init() {
this.dialogVisible = true;
},
},
};
</script>