el-dialog对话框子组件的关闭

在子组件对话框中 用: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>

猜你喜欢

转载自blog.csdn.net/Dolores_zsq/article/details/130637769
今日推荐