问题
In this tutorial, there is code that reads:
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();
}
});
});
For me, this leads to a 404 when the application is looking for the application code.
GET http://localhost:8000/AM/controller/Users.js?_dc=1394340001581 404 (File not found)
Why is it using the application name (AM) instead of the 'app' folder like usual? I tried setting the 'appFolder' config directly to no avail as well. It works fine when I create the application normally using
Ext.application({
name: 'AM',
// automatically create an instance of AM.view.Viewport
autoCreateViewport: true,
controllers: [
'Users'
]
});
I am serving the application with a simple http server from the root application directory (where the index.html and app.js live) and using extjs 4.2.1.883.
回答1:
You have to set the appFolder ex:
Ext.application({
name: 'AM',
appFolder: "Physical path of appfolder",
autoCreateViewport: true,
controllers: [
'Users'
]
});
Create the object for above class. You will get the correct path for controllers
回答2:
this is how to commonly configure the path mapping:
Ext.Loader.setConfig({
enabled: true,
paths: {
'AM': 'app'
}
});
回答3:
I never found out why it wasn't working for me, but to continue with the tutorial, I just used Ext.application instead and assigned the application to a global var in launch, i.e.:
Ext.application({
requires: ['Ext.container.Viewport'],
name: 'AM',
controllers: [
'Smiles'
],
autoCreateViewport: false,
launch: function() {
window.Application = this;
}
});
来源:https://stackoverflow.com/questions/22278512/extjs-application-not-looking-in-the-correct-app-folder