调用基类方法似乎对我不起作用。 我有以下设置:
...
<div class='my'></div>
...
和Javascript
$.widget('tt.name1',{
_create: function() {
this.name = 'name'
console.log('-->', this.name);
}
});
$.widget('tt.name2',$.tt.name1, {
_create: function() {
this._super();
/*$.tt.name1.prototype._create.call(this);*/
this.name = 'name2'
console.log('-->', this.name);
}
});
$('.my').name1();
$('.my').name2();
在调用this._super()
- &GT;命名
未捕获的TypeError:对象#没有方法'_super'
答案 0 :(得分:6)
这些示例使用jQuery 1.9中引入的小部件工厂。您的示例使用1.8.9。如果升级到1.9,您的代码将正常工作。