本文介绍: 在子组件对话框中 用:beforeclose关闭对话框取消按键绑定点击事件。父组件中@close接收组件传来的“close”事件。子组件把”close”事件传给父组件

在子组件对话框中 用:before-close关闭对话框,取消按键绑定点击事件

<el-dialog :title="title" :visible.sync="dialogVisible" width="30%" :before-close="close">
  <div style="display: flex;justify-content:space-around ;flex: 1;">
    <el-button @click="close">取 消</el-button>
    <el-button type="primary" >确 定</el-button>
  </div>
</el-dialog>

组件把”close”事件传给父组件 

methods: {
        close() {
            this.$emit("close")
        },
    }

父组件中@close接收子组件传来的“close”事件 

<clue-assign-dialog 
  ref="clueAssign" 
  :dialog-visible="dialogVisible" 
  :title="title" 
  @close="dialogVisible = false">
</clue-assign-dialog>

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注