为了方便JsonRest商店使用非标准的url方案,我试图继承JsonRest并覆盖该_getTarget(id)函数.这是我继承的javascript类的样子:
define([
"dojo/_base/declare",
"dojo/store/JsonRest",
],
function(declare, JsonRest) {
return declare(JsonRest, {
_getTarget: function(id){
var target = this.target;
if(typeof id != "undefined"){
if(target.indexOf("{id}") != -1) {
//use template
target = target.replace("{id}", id);
} else {
target = this.inherited(id);
}
}
return target;
},
});
});
Run Code Online (Sandbox Code Playgroud)
但是该行target = this.inherited(id);返回错误:Uncaught TypeError: Cannot read property 'callee' of undefined.
我查看了文档,我认为我做得对:http: //dojotoolkit.org/reference-guide/1.10/dojo/_base/declare.html#calling-superclass-methods
调用基类_getTarget(id)函数的正确方法是什么?
如果你看看你链接的文档密切的部分,你应该从字面上的传递arguments对象this.inherited-这就是包含了callee它正在寻找(并包括物业id及任何其他参数无论如何,要沿着传递到超) .
在几个段落中,文档还解释了如何this.inherited使用除了传递相同参数之外的参数进行调用(如果需要):您可以在数组之后 传递自定义参数arguments,即this.inherited(arguments, [ ... ]). arguments总是必须先.
| 归档时间: |
|
| 查看次数: |
762 次 |
| 最近记录: |