手动构造函数链接与dojo:参数问题

unl*_*udo 1 dojo inheritance constructor

我正在尝试创建一个继承一个类的类.

在这个类中,我想创建2个对象,这些对象将被传递给父类的构造函数.

要做到这一点,我必须使用手动构造函数链接并调用'inherited'(请参阅http://dojotoolkit.org/reference-guide/1.7/dojo/declare.html#manual-constructor-chaining)

我的问题是我无法正确地将参数传递给继承的方法.当我使用followind代码时:

   define([ "dojo/_base/declare", "dojo/store/JsonRest", "dojo/store/Memory", "dojo/store/Cache", "dojo/store/Observable"],

   function(declare, JsonRest, Memory, Cache, Observable)
   {
      var userStore;
      return declare("app.UserStore", [Cache],
         {
            "-chains-":
            {
               constructor: "manual"
            },
            constructor: function()
            {
               this.masterStore = new JsonRest({
                  target: "/User/json",
                  idProperty: "name"
               });

               this.cacheStore = new Memory({ idProperty: "name" });

               this.inherited([this.masterStore, this.cacheStore]);
            }
         });
   });
Run Code Online (Sandbox Code Playgroud)

我在declare.js中得到了一个未定义的arg.callee.

当我将'arguments'作为参数传递给inherited时,定义了callee.是否可以动态地向arguments对象添加更多参数?

如果不是,我怎么能在这个构造函数中用动态创建的对象调用父类?

谢谢!

neo*_*art 5

this.inherited必须总是字面上的第一个参数arguments.这样就dojo.declare可以找出基于的超类方法arguments.callee.鉴于这种情况,如果你想向超类方法发送不同的参数,那么你应该有一个数组作为第二个参数this.inherited.我还没有确认这适用于构造函数,但我会尝试以下方法:

this.inherited(arguments, [this.masterStore, this.cacheStore]);
Run Code Online (Sandbox Code Playgroud)

我很想知道它是否有效.