读书人

prototype 有关问题

发布时间: 2013-03-04 17:22:13 作者: rapoo

求助——prototype 问题
为什么HTML5 CANVAS对象 context对象 的prototype属性 不能通过这种方法拓展对象的方法

var canvas=document.getElementById('test');
context = canvas.getContext('2d');
context.prototype.ttt=function(){
alert('s');
}

上面代码运行出错

Uncaught TypeError: Cannot set property 'ttt' of undefined prototype html5 canvas
[解决办法]
不是告诉你了context.prototype是undefined了吗?

读书人网 >JavaScript

热点推荐