重写elementUI的dialog組件
1.重写el-dialog:elOverlayAutoclose.js
import { Dialog } from 'element-ui' const DialogPathed = { extends: Dialog, data() { return { wrapperMouseDowned: false } }, methods: { handleWrapperClick() { if (!this.closeOnClickModal || !this.wrapperMouseDowned) return this.handleClose() } }, mounted() { this.$el.onmousedown = (e) => { this.wrapperMouseDowned = e.target.classList.contains('el-dialog__wrapper') } } } export default { install(Vue) { Vue.component(Dialog.name, DialogPathed) } }
2.main.js
// el-dialog重写,修复拖拽自动关闭问题 import PATCH_ElOverlayAutoclose from '@lvya-common/src/coms-common/dialog/elOverlayAutoclose' Vue.use(PATCH_ElOverlayAutoclose)