由于点右上角关闭按钮时不会触发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)
}