【发布时间】:2014-04-12 06:40:19
【问题描述】:
在这个tutorial 中,有一段代码如下:
Ext.require('Ext.app.Application');
var Application = null;
Ext.onReady(function() {
Application = Ext.create('Ext.app.Application', {
name: 'AM',
controllers: [
'Users'
],
launch: function() {
//include the tests in the test.html head
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
jasmine.getEnv().execute();
}
});
});
对我来说,当应用程序正在寻找应用程序代码时,这会导致 404。
GET http://localhost:8000/AM/controller/Users.js?_dc=1394340001581 404 (File not found)
为什么它使用应用程序名称 (AM) 而不是像往常一样使用“app”文件夹?我尝试直接设置“appFolder”配置也无济于事。当我使用
正常创建应用程序时,它工作正常Ext.application({
name: 'AM',
// automatically create an instance of AM.view.Viewport
autoCreateViewport: true,
controllers: [
'Users'
]
});
我正在使用来自根应用程序目录(index.html 和 app.js 所在的位置)的简单 http 服务器为应用程序提供服务,并使用 extjs 4.2.1.883。
【问题讨论】:
-
因为
Ext.application不仅仅是启动一个实例。您甚至可以在Ext-more.js的第 1420 行附近看到它的来源。 -
我讨厌这样没有意义的错误。然而应该注意的是,当使用 MVC 模式时,最好不要在 Ext.onReady 函数中启动您的应用程序。我在几个线程中阅读了此内容,但找不到原因。
-
我能够解析 Ext 示例资源,我只需要确保示例中的目录结构正确嵌套在我试图让 jasmine 进入的现有、正在运行的应用程序中。实际上验证应用程序启动并没有那么幸运,但是 Extjs 主要版本 = 4 测试运行良好。
标签: javascript extjs model-view-controller extjs4