context扩展及canvas的浏览器兼容

1、利用 CanvasRenderingContext2D.prototype 对context进行扩展

1 CanvasRenderingContext2D.prototype.drawLine = function(x1,y1,x2,y2){
2     this.moveTo(x1,y1);
3     this.lineTo(x2,y2);
4     this.stroke();
5 }
6 
7 context.drawLine(0,0,100,100)

2、在 IE8- 中使用canvas

  通过加载 ExplorerCanvas 第三方库解决兼容问题

  GitHub 地址:https://github.com/arv/explorercanvas

  使用方法:

  <!--[if lte IE 8]><script type="text/javascript" src="excanvas.js"></script><![endif]-->

 

posted @ 2017-11-23 16:31  穿山甲到底说了什么  阅读(325)  评论(0编辑  收藏  举报