1.回退方法 reBack_fun(){
let _this = this;
this.redo_index = this.redo_index - 1;
if(this.redo_index > 0){
let _img = new Image();
_img.src = '';
_img.src = this.imgCach_arr[this.redo_index - 1];
console.log(this.imgCach_arr,this.redo_index - 1);
// this.currentIndex = _len;
_img.onload = function(){
_this.ctx.drawImage(_img,0,0);
}
}
},
-
清除方法
clearImg_arr(){console.log(1) let _this = this; this.imgCach_arr = []; //清除图片的存储 this.ctx.clearRect(0, 0, this.casWidth, this.casHeight); },
3.每当清除之后就不能使用,什么原因?
是不是你这一句
this.imgCach_arr = []
把所有数据都给清除了,导致回退加载不到资源