ExtJS application not looking in the correct app f

2019-06-08 07:35发布

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.

3条回答
手持菜刀,她持情操
2楼-- · 2019-06-08 07:43

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;
    }
});
查看更多
走好不送
3楼-- · 2019-06-08 07:53

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

查看更多
beautiful°
4楼-- · 2019-06-08 07:57

this is how to commonly configure the path mapping:

Ext.Loader.setConfig({
    enabled: true,
    paths: {
        'AM': 'app'
    }
});
查看更多
登录 后发表回答