重写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)

 

posted @ 2023-07-21 09:24  卷叶小树  阅读(273)  评论(0编辑  收藏  举报