1 子组件child,dialogVisible控制弹框显示隐藏
<el-dialog
title="提示"
:visible.sync="dialogVisible"
width="30%"
:before-close="handleClose">
<span>这是一段信息</span>
<span slot="footer" class="dialog-footer">
<el-button @click="changeShow">取 消</el-button>
<el-button type="primary" @click="changeShow">确 定</el-button>
</span>
</el-dialog>
changeShow(){
this.dialogVisible = !this.dialogVisible
}
2 父组件parent引入子组件child,在子组件定义ref, 使用ref可以调用子组件的值和方法
<el-button @click="layerShow"></el-button>
<child ref="child" />
layerShow(){
this.$refs.child.changeShow()
}