canvas代替img渲染图片

移动端用canvas代替img渲染图片,可以提高性能

var oImg = new Image();
oImg.src = url;
oImg.onload = function(){
    var cvs = $('#cvsIndex')[0].getContext('2d');
    cvs.width = this.width;
    cvs.width = this.height;
    cvs.drawImage(this,0,0);
}

 

你可能感兴趣的:(canvas代替img渲染图片)