由于点右上角关闭按钮时不会触发handleCancel方法,改变visible的值,需增加@close="handleCancel"
<el-dialog
width="80%"
:visible.sync="visible"
title="上传图片"
:show-close="true"
close-on-click-modal="false"
append-to-body
@close="handleCancel"
>
<gd-form
ref="form"
style="width: 100%; max-width: 100%"
:fields="fields"
:buttons="buttons"
label-width="120px"
:disabled="readonly"
/>
<div v-show="!readonly" slot="footer" class="dialog-footer">
<el-button @click="handleCancel">取 消</el-button>
<el-button type="primary" @click="handleConfirm">保存</el-button>
</div>
</el-dialog>
</gl-container>
// 取消
handleCancel() {
this.$emit('update:visible', false)
}
本文讨论了在Vue组件中,如何修复点击El-dialog右上角关闭按钮时不调用handleCancel方法的问题,通过修改`@close=handleCancel`来确保关闭事件处理。
2万+

被折叠的 条评论
为什么被折叠?



