element ui Dialog对话框 点×触发事件
点击标题右上角的×执行的事件使用的是自己手写的方法
用slot绑定重写
使用本身的 before-close、destroy-on-close、close均没有用
:close-on-click-modal=“false” // 点击遮罩不关闭
:show-close=“false” // 不显示关闭按钮
<template>
<el-dialog :visible.sync="dialogFormVisible" :close-on-click-modal="false" :show-close="false">
<div slot="title" class="header-title">
<span style="font-size:18px;color:#333333;">新增二级分类</span>
<span style="float: right;font-size: 24px;padding: 0 10px;cursor: pointer;" @click="closeDialog">×</span>
</div>
<el-form :model="form">
<el-form-item label="分类名称" :label-width="formLabelWidth">
<el-input
v-model="form.name"
autocomplete="off"
placeholder="请输入分类名称,最多十个字"
maxlength="10"
show-word-limit></el-input>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="cancelFun">取 消</el-button>
<el-button type="primary" @click="onSubmit">确 定</el-button>
</div>
</el-dialog>
</template>
data () {
return {
dialogFormVisible: true,
form: {
name: ''
},
formLabelWidth: '120px'
}
},
methods: {
// 关闭弹框的事件
closeDialog () {
this.form.name = ''
this.dialogFormVisible = false
},
// 点击取消事件
cancelFun () {
this.dialogFormVisible = false
this.form.name = ''
},
// 点击确定事件
onSubmit () {
if (this.form.name === '') {
this.commonTip('请输入分类名称')
return false
}
this.dialogFormVisible = false
// 这里写你确定之后的事件
}
}