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);
}

 

posted @ 2016-02-06 13:49  全玉  阅读(1535)  评论(0编辑  收藏  举报