我有一个定义模块的文件,如:
define([
"xstyle/css!./less/layout.less",
"dojo", "dojo/parser", "dojo/store/Memory", "dojo/dom-style", "dojo/dom-construct", "dojo/store/Observable", "dojo/_base/declare", "dojo/query", "dojo/dom-attr", "dojo/on", "dojo/request/xhr", "dojo/sniff", "dojo/keys", "dojo/string", "dojo/topic", "dojo/date/locale", "dojo/date/stamp", "dojo/date", "dojo/store/JsonRest", "dojo/number", "dojo/_base/lang",
"dijit", "dijit/PopupMenuItem", "dijit/Menu", "dijit/MenuItem", "dijit/form/Select", "dijit/Dialog", "dijit/layout/ContentPane", "dijit/Toolbar", "dijit/form/Button", "dijit/form/ValidationTextBox", "dijit/form/FilteringSelect",
"dojox/layout/TableContainer",
"dgrid/editor", "dgrid/Keyboard", "dgrid/selector"
],
function(
less,
dojo, parser, MemoryStore, domStyle, domConstruct, Observable, declare, query, domAttr, on, xhr, has, keys, string, topic, localeDate, stamp, dojoDate, JsonRest, dojoNumber, lang,
dijit, PopupMenuItem, Menu, MenuItem, Select, Dialog, ContentPane, Toolbar, Button, TextBox, FilteringSelect,
TableContainer,
editor, Keyboard, selector
) {
function createWidgetSpecified(root, collectionsToolbar){
...
}
function getCollectionGrid(root, fieldCode, style){
....
}
function filterDocumentTypeFieldsForNonByte(documentData){
.....
}
...
return declare(Dialog, {
...,
...,
constructor: function(args){
lang.mixin(this, args);
},
createIssuerInfo: function(issuerData){
...
},
createMatcher: function(root){
...
},
...
});
});
我希望与另一个人混在一起。 对我来说,重要的想法是: 替换或添加新函数(未在类中声明)。例如,我想用其新版本替换createWidgetSpecified,并添加另外两个函数,如:startSave,startDelete。我怎么能这样做?
我没有提到那些功能只在运行时才知道。我的意思是我定义的模块是使用参数类型= 26创建的。我想从文件加载该函数:../ js / fortype / 26 / document.js for type 26
像: var moduleObject = new Module({type:26}); 我想动态加载类型26的函数
答案 0 :(得分:0)
在文件A中:
define([
...,
"./FileB"
], function (
..., FileB) {
return declare([otherMixins, FileB], {
// functions in File A
});
});
在文件B中:
define([
...
], function (
...) {
return declare([], {
// functions in File B
});
});