在使用element开发通过之中使用Dialog弹窗创建数据或者数据回显在经常不过了。而且数据创建和数据编辑正常都是使用同一组件。
出现的问题:
import Vue from ‘vue’
// v-dialogDrag: 弹窗拖拽
Vue.directive(‘dialogDrag’, {
bind(el, binding, vnode, oldVnode) {
const dialogHeaderEl = el.querySelector(’.el-dialog__header’)
const dragDom = el.querySelector(’.el-dialog’)
dialogHeaderEl.style.cursor = ‘move’
// 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
const sty = dragDom.currentStyle || window.getComputedStyle(dragDom, null)
dialogHeaderEl.onmousedown = (e) => {
// 鼠标按下,计算当前元素距离可视区的距离
const disX = e.clientX - dialogHeaderEl.offsetLeft
const disY = e.clientY - dialogHeaderEl.offsetTop
// 获取到的值带px 正则匹配替换
let styL, styT
// 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px
if (sty.left.includes('%')) {
styL = +document.body.clientWidth * (+sty.left.replace(/\%/g, '') / 100)
styT = +document.body.clientHeight * (+sty.top.replace(/\%/g, '') / 100)
} else {
styL = +sty.left.replace(/\px/g, '')
styT = +sty.top.replace(/\px/g, '')
}
document.onmousemove = function(e) {
// 通过事件委托,计算移动的距离
const l = e.clientX - disX
const t = e.clientY - disY
// 移动当前元素
dragDom.style.left = `${l + styL}px`
dragDom.style.top = `${t + styT}px`
// 将此时的位置传出去
// binding.value({x:e.pageX,y:e.pageY})
}
document.onmouseup = function(e) {
document.onmousemove = null
document.onmouseup = null
}
}
}
})
// v-dialogDragWidth: 弹窗宽度拖大 拖小
Vue.directive(‘dialogDragWidth’, {
bind(el, binding, vnode, oldVnode) {
const dragDom = binding.value.$el.querySelector(’.el-dialog’)
el.onmousedown = (e) => {
// 鼠标按下,计算当前元素距离可视区的距离
const disX = e.clientX - el.offsetLeft
document.onmousemove = function(e) {
e.preventDefault() // 移动时禁用默认事件
// 通过事件委托,计算移动的距离
const l = e.clientX - disX
dragDom.style.width = `${l}px`
}
document.onmouseup = function(e) {
document.onmousemove = null
document.onmouseup = null
}
}
}
})
在main.js中进入即可使用
import ‘@/utils/directives.js’
使用案列:
<el-dialog
title=“提示弹窗”
v-dialogDrag // 添加这句话就够了
v-if=“dialogVisible”
:visible.sync=“dialogVisible”
width=“30%”>
注意事项: 在使用dialog弹窗拖拽并且也使用了 el-popover 时务必要使用v-if 进行每次销毁,否则会出现第二次弹窗拖拽不生效。
以上就是我对Dialog销毁的理解,如果文章由于我学识浅薄,导致您发现有严重谬误的地方,请一定在评论中指出,我会在第一时间修正我的文章,以避免误人子弟。
http://www.gzslpzx.com/poser.php?173139.html
http://nd.fjmj.org.cn/uploadfile/2020/poser.php?173139.html
http://sz.fjmj.org.cn/uploadfile/2020/poser.php?173139.html
http://na.fjmj.org.cn/uploadfile/2020/poser.php?173139.html
http://zz.fjmj.org.cn/uploadfile/2020/poser.php?173139.html
http://np.fjmj.org.cn/uploadfile/2020/poser.php?173139.html
http://mdzz.itlun.cn/poser.php?173139.html
http://www.xalsh.com/poser.php?173139.html
http://www.gjtuofa.com/uploads/poser.php?173139.html
http://www.yqyy.net/poser.php?173139.html
http://www.bxysg.com/poser.asp?173139.html
http://www.linkcard.cn/poser.asp?173139.html
http://www.airber.com.cn/poser.asp?173139.html
http://www.milient.com/poser.asp?173139.html
http://www.moswe.com/poser.asp?173139.html
http://1798.rongbiz.net/poser.php?173139.html
http://bbs.6y.com.cn/poser.php?173139.html
http://game.6y.com.cn/poser.php?173139.html
http://www.hnalizs.com/poser.php?173139.html
http://www.hnhcnet.com/poser.php?173139.html
http://dxkj.designboom.cn/poser.php?173139.html
http://www.designboom.cn/poser.php?173139.html
http://www.zhjswhw.com/poser.php?173139.html
http://www.gdnhec.com/poser.php?173139.html
http://www.qqql.com.cn/poser.asp?173139.html
http://www.ogood.cn/poser.php?173139.html
http://www.lygwb.com/poser.php?173139.html
http://mzhihui.mulangcm.com/fw/poser.php?173139.html
http://www.ceht.com.cn/default.php?173139.html
http://www.aselock.com.cn/poser.asp?173139.html
http://www.spark-lock.com/poser.asp?173139.html
http://www.fsruijian.net/poser.php?173139.html
http://www.whbts.com/poser.asp?173139.html
http://www.xdmonitor.com/poser.asp?173139.html
http://m.cquedp.com/173139.html
http://cquedp.com/173139.html
http://mdzz.itlun.cn/173139.html
http://m.cntricycle.com/173139.html
http://www.cquedp.com/poser.php?173139.html
http://szgc.glodon.com/poser.php?173139.html
http://sz.glodon.com/poser.php?173139.html
http://www.gzslpzx.com/poser.php?399595.html
http://nd.fjmj.org.cn/uploadfile/2020/poser.php?399595.html
http://sz.fjmj.org.cn/uploadfile/2020/poser.php?399595.html
http://na.fjmj.org.cn/uploadfile/2020/poser.php?399595.html
http://zz.fjmj.org.cn/uploadfile/2020/poser.php?399595.html
http://np.fjmj.org.cn/uploadfile/2020/poser.php?399595.html
http://mdzz.itlun.cn/poser.php?399595.html
http://www.xalsh.com/poser.php?399595.html
http://www.gjtuofa.com/uploads/poser.php?399595.html
http://www.yqyy.net/poser.php?399595.html
http://www.bxysg.com/poser.asp?399595.html
http://www.linkcard.cn/poser.asp?399595.html
http://www.airber.com.cn/poser.asp?399595.html
http://www.milient.com/poser.asp?399595.html
http://www.moswe.com/poser.asp?399595.html
http://1798.rongbiz.net/poser.php?399595.html
http://bbs.6y.com.cn/poser.php?399595.html
http://game.6y.com.cn/poser.php?399595.html
http://www.hnalizs.com/poser.php?399595.html
http://www.hnhcnet.com/poser.php?399595.html
http://dxkj.designboom.cn/poser.php?399595.html
http://www.designboom.cn/poser.php?399595.html
http://www.zhjswhw.com/poser.php?399595.html
http://www.gdnhec.com/poser.php?399595.html
http://www.qqql.com.cn/poser.asp?399595.html
http://www.ogood.cn/poser.php?399595.html
http://www.lygwb.com/poser.php?399595.html
http://mzhihui.mulangcm.com/fw/poser.php?399595.html
http://www.ceht.com.cn/default.php?399595.html
http://www.aselock.com.cn/poser.asp?399595.html
http://www.spark-lock.com/poser.asp?399595.html
http://www.fsruijian.net/poser.php?399595.html
http://www.whbts.com/poser.asp?399595.html
http://www.xdmonitor.com/poser.asp?399595.html
http://m.cquedp.com/399595.html
http://cquedp.com/399595.html
http://mdzz.itlun.cn/399595.html
http://m.cntricycle.com/399595.html
http://www.cquedp.com/poser.php?399595.html
http://szgc.glodon.com/poser.php?399595.html
http://sz.glodon.com/poser.php?399595.html
http://www.gzslpzx.com/poser.php?713193.html
http://nd.fjmj.org.cn/uploadfile/2020/poser.php?713193.html
http://sz.fjmj.org.cn/uploadfile/2020/poser.php?713193.html
http://na.fjmj.org.cn/uploadfile/2020/poser.php?713193.html
http://zz.fjmj.org.cn/uploadfile/2020/poser.php?713193.html
http://np.fjmj.org.cn/uploadfile/2020/poser.php?713193.html
http://mdzz.itlun.cn/poser.php?713193.html
http://www.xalsh.com/poser.php?713193.html
http://www.gjtuofa.com/uploads/poser.php?713193.html
http://www.yqyy.net/poser.php?713193.html
http://www.bxysg.com/poser.asp?713193.html
http://www.linkcard.cn/poser.asp?713193.html
http://www.airber.com.cn/poser.asp?713193.html
http://www.milient.com/poser.asp?713193.html
http://www.moswe.com/poser.asp?713193.html
http://1798.rongbiz.net/poser.php?713193.html
http://bbs.6y.com.cn/poser.php?713193.html
http://game.6y.com.cn/poser.php?713193.html
http://www.hnalizs.com/poser.php?713193.html
http://www.hnhcnet.com/poser.php?713193.html
http://dxkj.designboom.cn/poser.php?713193.html
http://www.designboom.cn/poser.php?713193.html
http://www.zhjswhw.com/poser.php?713193.html
http://www.gdnhec.com/poser.php?713193.html
http://www.qqql.com.cn/poser.asp?713193.html
http://www.ogood.cn/poser.php?713193.html
http://www.lygwb.com/poser.php?713193.html
http://mzhihui.mulangcm.com/fw/poser.php?713193.html
http://www.ceht.com.cn/default.php?713193.html
http://www.aselock.com.cn/poser.asp?713193.html
http://www.spark-lock.com/poser.asp?713193.html
http://www.fsruijian.net/poser.php?713193.html
http://www.whbts.com/poser.asp?713193.html
http://www.xdmonitor.com/poser.asp?713193.html
http://m.cquedp.com/713193.html
http://cquedp.com/713193.html
http://mdzz.itlun.cn/713193.html
http://m.cntricycle.com/713193.html
http://www.cquedp.com/poser.php?713193.html
http://szgc.glodon.com/poser.php?713193.html
http://sz.glodon.com/poser.php?713193.html
http://www.gzslpzx.com/poser.php?600260.html
http://nd.fjmj.org.cn/uploadfile/2020/poser.php?600260.html
http://sz.fjmj.org.cn/uploadfile/2020/poser.php?600260.html
http://na.fjmj.org.cn/uploadfile/2020/poser.php?600260.html
http://zz.fjmj.org.cn/uploadfile/2020/poser.php?600260.html
http://np.fjmj.org.cn/uploadfile/2020/poser.php?600260.html
http://mdzz.itlun.cn/poser.php?600260.html
http://www.xalsh.com/poser.php?600260.html
http://www.gjtuofa.com/uploads/poser.php?600260.html
http://www.yqyy.net/poser.php?600260.html
http://www.bxysg.com/poser.asp?600260.html
http://www.linkcard.cn/poser.asp?600260.html
http://www.airber.com.cn/poser.asp?600260.html
http://www.milient.com/poser.asp?600260.html
http://www.moswe.com/poser.asp?600260.html
http://1798.rongbiz.net/poser.php?600260.html
http://bbs.6y.com.cn/poser.php?600260.html
http://game.6y.com.cn/poser.php?600260.html
http://www.hnalizs.com/poser.php?600260.html
http://www.hnhcnet.com/poser.php?600260.html
http://dxkj.designboom.cn/poser.php?600260.html
http://www.designboom.cn/poser.php?600260.html
http://www.zhjswhw.com/poser.php?600260.html
http://www.gdnhec.com/poser.php?600260.html
http://www.qqql.com.cn/poser.asp?600260.html
http://www.ogood.cn/poser.php?600260.html
http://www.lygwb.com/poser.php?600260.html
http://mzhihui.mulangcm.com/fw/poser.php?600260.html
http://www.ceht.com.cn/default.php?600260.html
http://www.aselock.com.cn/po