ExtJS 6查看自动加载器问题

时间:2017-04-27 12:59:00

标签: extjs autoloader

ExtJS 6.5.0:在应用程序中使用

appFolder: '/app/document/app'

但它看起来不适用于观点:

>> Ext.Loader.getPath('Document');
/app/document/app

>> Ext.Loader.getPath('Document.view.main.Main');
classic/src/view/main/Main.js
{OR} modern/src/view/main/Main.js
// Expected:
// /app/document/app/classic/src/view/main/Main.js
// OR /app/document/app/modern/src/view/main/Main.js

>> Ext.Loader.getPath('Document.main.Main');
/app/document/app/main/Main.js

有人可以为此提出解决方案吗?

重现问题的步骤:

sencha generate workspace ./
sencha framework add ~/extjs/6.5.0 ext
sencha -sdk ext generate app Document ./app/document

nano ./app/document/app.js
> + appFolder: '/app/documents/app',

将索引文件向上移动两个文件夹...打开控制台并从顶部检查命令。

P.S。我已经在Ext.beforeLoad做了一个黑客来解决它,但我需要一个直接“开箱即用”的解决方案

2 个答案:

答案 0 :(得分:2)

我认为你已经创建了一个Universal应用程序。

Universal应用程序有两个单独的文件夹,用于classicmodern次观看。

EXTJS 6将期望classicmodern文件夹中的所有视图文件为相应类型,并且它将根据您的加载描述符在运行时对视图进行排序。你可以在运行时给出。

  

Ext.manifest ='经典'或'现代';

enter image description here

答案 1 :(得分:1)

以下是来自https://www.sencha.com/forum/showthread.php?269448-Cmd-3-1-2-Ext-Loader-path-prefix的方法:

  

要从页面位置的上下文以外的地方动态加载资源,而不使用基本标记,我认为实际上必须弄乱加载程序配置。类似的东西:

     

代码:

Ext.Loader.setPath({
    "Ext":              "http://path/ext/src",
    "MyApp":            "http://path/app",
    "MyApp.model":      "http://path/app/model",
    "MyApp.view":       "http://path/app/view",
    "MyApp.controller": "http://path/app/controller",
    "MyApp.store":      "http://path/app/store",
    "MyApp.extras":     "http://path/app/extras"

});

  

命名空间需要“过度指定”,因为Ext.application会通过使用MyApp.appFolder的值覆盖自动加载器的MyApp路径(这实际上不应该是绝对路径;甚至架构师也不会允许你设置一个。)