Dojo this.inherit throws 'Uncaught TypeError: Cannot read property 'callee' of undefined'

Dojo this.inherit throws 'Uncaught TypeError: Cannot read property 'callee' of undefined'

为了方便使用非标准 url 方案的 JsonRest 存储,我试图继承 JsonRest 并覆盖 _getTarget(id) 函数。这是我继承的 javascript class 的样子:

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;
        },
    });
});

然而target = this.inherited(id);行returns报错:Uncaught TypeError: Cannot read property 'callee' of undefined.

我查看了文档,我认为我做的是对的: http://dojotoolkit.org/reference-guide/1.10/dojo/_base/declare.html#calling-superclass-methods

调用基础 class 的 _getTarget(id) 函数的正确方法是什么?

如果您仔细查看链接的文档部分,您应该 字面上 arguments 对象传递给 this.inherited - 这就是包含的内容它正在寻找的 callee 属性(并且无论如何都会包括 id 和任何其他参数,以传递给超类)。

文档中的几段还解释了如何调用 this.inherited 使用与传递的参数不同的参数,如有必要:您可以在数组 after[= 中传递自定义参数24=]arguments,即this.inherited(arguments, [ ... ])arguments 总是第一个。