vue 实现div拖拽功能

arrowMove(e) { // 拖拽设备域 // 元素大小 let elW = e.currentTarget.offsetWidth let elH = e.currentTarget.offsetHeight // 元素位置 let elL = e.currentTarget.offsetLeft let elT = e.currentTarget.offsetTop // 鼠标位置 let x = e.clientX let y = e.clientY // 窗口大小 let w = window.innerWidth let h = window.innerHeight // 鼠标到元素左边距离 let moveX = x - elL let moveY = y - elT let el = e.currentTarget document.onmousemove = function (e) { el.style.left = e.clientX - moveX + 'px' el.style.top = e.clientY - moveY + 'px' } document.onmouseup = function () { document.onmousemove = null document.onmouseup = null } },

你可能感兴趣的:(javascript,vue.js,javascript,前端)