我找到了原因(请耐心等待):
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 在 ext 5 和 6 中是相同的
那么为什么它在 ExtJs 5 中
Ext.getNamespace("MyApp.controller.SomeController"); // returns MyApp
在 ExtJs 6 上
Ext.getNamespace("MyApp.controller.SomeController"); // returns MyApp.controller
原因由 console.log 找到,Ext.ClassManager.paths
现在有一个新条目对应于MyApp.controller
以前没有 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;
}
}
如果您知道更好的解决方案,请告诉我!