<canvas id="canvas" width="1000" height="500" style="background:#333"></canvas>
//html代码
var canvas = document.getElementById('canvas'),
cvs = canvas.getContext('2d');
(function motion(){
cvs.clearRect(0,0,canvas.width,canvas.height);//为什么加上这条就无法显示图片了?
img();
console.log(1)
requestAnimationFrame(motion);
})();
function img(){
var Img = new Image();
Img.src = 'https://www.baidu.com/img/bd_logo1.png';
Img.onload = function(){
cvs.drawImage(Img,100,100);
};
};
img();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…