在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML5  HTML/ canvas 清除數(shù)據(jù)回退不能使用?

canvas 清除數(shù)據(jù)回退不能使用?

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);
                }
            }
        },
  1. 清除方法
    clearImg_arr(){

            console.log(1)
            let _this = this;
            this.imgCach_arr = [];   //清除圖片的存儲(chǔ)
            this.ctx.clearRect(0, 0, this.casWidth, this.casHeight);
        },   
        

3.每當(dāng)清除之后就不能使用,什么原因?

回答
編輯回答
九年囚

是不是你這一句
this.imgCach_arr = []
把所有數(shù)據(jù)都給清除了,導(dǎo)致回退加載不到資源

2017年8月11日 20:53