当我创建 ClickEvent 对象的新实例时,它返回以下错误。单击此处获取 jsfiddle 代码。下面是我的代码
var ClickEvent = function (event) {
this.ev = $('.' + event);
this.ev.on('click', this.userInput());
};
ClickEvent.protoype = function () {
return {
userInput: function () {
console.log('user');
},
show: function () {
console.log('show');
}
};
}();
var c = new ClickEvent('event');
c.show();
为什么会显示此错误,我该如何解决?
Uncaught TypeError: Object [object Object] has no method 'userInput'