我想創建一個繼承一個類的類。手動構造函數與dojo鏈接:參數問題
在這個類中,我想創建2個將傳遞給父類構造函數的對象。
要做到這一點,我不得不使用人工構造函數鏈和稱之爲「繼承」(見http://dojotoolkit.org/reference-guide/1.7/dojo/declare.html#manual-constructor-chaining)
我的問題是,我不能正確地將參數傳遞給繼承的方法。當我使用後續代碼時:
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]);
}
});
});
我在declare.js中得到了未定義的arg.callee。
當我將'參數'作爲參數傳遞給繼承,然後定義了被調用者。是否可以動態添加更多的參數給參數對象?
如果不是我可以調用與此構造函數動態創建的對象的父?
謝謝!
謝謝!這就是我所做的,進一步閱讀文檔。所以它修復了對父構造函數的調用問題。現在的問題是,當我創建這個對象,我要緩存功能用不上(獲取,查詢,...)。所以還是有些問題。 – unludo 2012-03-24 09:34:26