vue自定义指令实现可拖动变div宽度大小
// dragSize.js 文件
const touch = { lastTime: 0, interval: 300, startX: 0 };
let move = 0, element, min = 200, max = 230;
//move 是鼠标移动的距离,min和max是可拖动范围
function mousemove_(e) {
if (!touch.init) return;
move = e.pageX - touch.startX;
element.style.width =
touch.width + move + "px";
if (touch.width + move > max) {
element.style.width = max + "px";
}
if (touch.width + move < min) {
element.style.width = min + "px";
}
}
function mouseup_() {
if (!touch.init) return;
touch.init = false
document.removeEventListener('mousemove', mousemove_)
document.removeEventListener('mouseup', mouseup_)
}
e