我已經找到了原因(裸與我):
https://docs.sencha.com/extjs/6.0/6.0.2-classic/source/Controller2.html#Ext-app-Controller
看看:
onClassExtended - > Controller.resolveNamespace - > Ext.app.getNamespace
這些是重要的,一旦命名空間解決了就有一個調用來處理依賴關係:
Controller.processDependencies(proto, requires, namespace, 'store', data.stores);
我研究這一點,並Ext.app.getNamespace是在分機5和6
所以爲什麼它在ExtJs的5
Ext.getNamespace("MyApp.controller.SomeController"); // returns MyApp
和ExtJs的6個相同
Ext.getNamespace("MyApp.controller.SomeController"); // returns MyApp.controller
原因是由控制檯發現的。登錄Ext.ClassManager.paths
現在有相當於MyApp.controller
![enter image description here](https://i.stack.imgur.com/MOm0y.png)
一個新條目以前有對MyApp.controller(ZHT.controller)無鑰匙
而且確實是尋找什麼Ext.getNameSpace爲'最深的前綴」,你可以在這裏看到http://docs.sencha.com/extjs/6.0/6.0.2-classic/source/Util.html#Ext-app-Util
[更新] 這麼一兩件事是可以做的是重寫靜態方法resolveNamespace像這樣:
statics: {
resolveNamespace: function(cls, data) {
var Controller = Ext.app.Controller,
namespaceRe = cls.prototype.isProfile ? Controller.profileRegex : Controller.controllerRegex,
className, namespace, match;
/*
* Namespace resolution is tricky business: we should know what namespace
* this Controller descendant belongs to, or model/store/view dependency
* resolution will be either ambiguous or plainly not possible. To avoid
* guessing games we try to look for a forward hint ($namespace) that
* Application class sets when its onClassExtended gets processed; if that
* fails we try to deduce namespace from class name.
*
* Note that for Ext.app.Application, Controller.onClassExtended gets executed
* *before* Application.onClassExtended so we have to delay namespace handling
* until after Application.onClassExtended kicks in, hence it is done in this hook.
*/
className = Ext.getClassName(cls);
namespace = data.$namespace || data.namespace ||
Ext.app.getNamespace(className) ||
((match = namespaceRe.exec(className)) && match[1]);
//<debug>
if (!namespace) {
Ext.log.warn("Missing namespace for " + className + ", please define it "+
"in namespaces property of your Application class.");
}
//</debug>
//This is the only change on this override.
//http://stackoverflow.com/questions/37731213/extjs-6-stores-config-on-ext-app-controller-not-working/37733261#37733261
if(namespace && namespace.indexOf(".controller") > -1) {
namespace = namespace.slice(0, namespace.indexOf(".controller"));
}
return namespace;
}
}
如果您知道更好的解決方案,請告訴我!
您是否需要控制器中的商店?這個例子表明它是必要的:[Ext.app.Controller#cfg-stores](http://docs.sencha.com/extjs/6.0.2-classic/Ext.app.Controller.html#cfg-stores)。 –
商店:['Menu'] 應該是你所需要的所有 –