之前有个项目需求是,在截图完成之后 自动给服务器发送请求,cropper插件里有截图框移动的回调函数@cropMoving
但是用了这个函数之后,截图框一移动就会请求。所以这时候需要防抖处理了
// 截图框移动回调函数
cropMoving(data) {
// 做一下防抖处理
this.time++;
if (this.time > 1) {
return;
} else {
// 截图框的左上角 和右下角坐标
this.cropAxis = [
data.axis.x1,
data.axis.y1,
data.axis.x2,
data.axis.y2
];
setTimeout(() => {
this.identifying = true;
this.handleUse();
this.time = 0;
}, 1000);
}
},