一、需求弹框可以任意拖拽位置,并且关闭重置不影响下一个弹框出现的位置
首先建的新的js文件draggable.j s具体位置随意
// draggable.js
export default {bind(el, binding, vnode) {const dialogHeaderEl = el.querySelector('.el-dialog__header');const dragDom = el.querySelector('.el-dialog');dialogHeaderEl.style.cursor = 'move';const getStyle = (function() {if (window.document.currentStyle) {return (dom, attr) => dom.currentStyle[attr];} else {return (dom, attr) => getComputedStyle(dom, false)[attr];}})();dialogHeaderEl.onmousedown = (e) => {// 鼠标按下,计算当前元素距离可视区的距离const disX = e.clientX - dialogHeaderEl.offsetLeft;const disY = e.clientY - dialogHeaderEl.offsetTop;const dragDomWidth = dragDom.offsetWidth;const dragDomHeight = dragDom.offsetHe