antdv弹窗modal可拖动方法
this.$nextTick(()=>{ const modal:any = document.getElementsByClassName('ant-modal')[0] const content:any = document.getElementsByClassName('ant-modal-content')[0] let left = 0 let top = 0 // 设置遮罩层可滚动 setTimeout(() => { document.body.style.width = '100%' document.body.style.overflowY = 'inherit' }, 0) // 鼠标变成可移动的指示 content.style.cursor = 'move' // top 初始值为 offsetTop top = top || modal.offsetTop content.onmousedown = e => { const startX = e.clientX const startY = e.clientY content.left = content.offsetLeft content.top = content.offsetTop document.onmousemove = event => { const endX = event.clientX const endY = event.clientY modal.left = content.left + (endX - startX) + left modal.top = content.top + (endY - startY) + top modal.style.left = modal.left + 'px' modal.style.top = modal.top + 'px' } document.onmouseup = event => { left = modal.left top = modal.top document.onmousemove = null document.onmouseup = null content.releaseCapture && content.releaseCapture() } content.setCapture && content.setCapture() } })