【问题标题】:Extjs 4.2 returns " NetworkError: 404 Not Found " errorExtjs 4.2 返回“NetworkError: 404 Not Found”错误
【发布时间】:2014-08-16 13:18:16
【问题描述】:

我是 extjs 的新手。我尝试使用 MVC 架构编写一个简单的应用程序,如下所述: http://docs-origin.sencha.com/extjs/4.2.1

当我尝试在浏览器中运行应用程序时,我在 firebug 中给出了这个错误:

"NetworkError: 404 Not Found - http://127.0.0.1/Sample/app/view/userlist.js?_dc=1408194279243"

我的项目结构是:

List.js 文件:

/**
 * Created by Sina-PC on 8/14/14.
 */
Ext.define('Sample.view.users.List' ,{
    extend: 'Ext.grid.Panel',
    alias: 'widget.userlist',

    title: 'All Users',

    initComponent: function() {
        this.store = {
            fields: ['name', 'email'],
            data  : [
                {name: 'Ed',    email: 'ed@sencha.com'},
                {name: 'Tommy', email: 'tommy@sencha.com'}
            ]
        };

        this.columns = [
            {header: 'Name',  dataIndex: 'name',  flex: 1},
            {header: 'Email', dataIndex: 'email', flex: 1}
        ];

        this.callParent(arguments);
    }
});

Users.js 文件:

Ext.define('Sample.controller.Users', {
    extend: 'Ext.app.Controller',
    views:['userlist'],
    init: function() {
        console.log('Initzed Users! This happens before the Application launch function is called');

        this.control({
            'viewport > panel': {
                render: this.onPanelRendered
            }
        });
    }
    ,
    onPanelRendered: function() {
        console.log('The panel was rendered');
    }
});/**
 * Created by Sina-PC on 8/14/14.
 */

app.js 文件:

Ext.application({
    name: 'Sample',
    appFolder:'app',

    controllers:[
        'Users'
    ],
    launch: function() {
        Ext.create('Ext.container.Viewport', {
            layout: 'fit',
            items: [
                {
                    xtype: 'userlist'
                }
            ]
        });

    }
});

和 index.html:

<html>
<head>
    <title>Hello Ext</title>

    <link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css">
    <script type="text/javascript" src="extjs/ext-all-debug.js"></script>
    <script type="text/javascript" src="app.js"></script>
</head>
<body></body>
</html>

【问题讨论】:

    标签: extjs extjs4.2


    【解决方案1】:

    ExtJs 不知道什么是视图“用户列表”。您必须添加到需要此文件。

    Ext.define('Sample.controller.Users', {
    
    requires: [ 'Sample.view.users.List' ],
    
    ...
    

    【讨论】:

      【解决方案2】:

      Users.js 文件有“views:['userlist']”,它应该是“views:['Sample.view.users.List']”,

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-08-16
        • 2014-07-29
        • 2016-08-21
        • 2012-08-16
        • 2019-12-09
        • 2018-12-16
        • 2015-03-20
        • 2015-01-04
        相关资源
        最近更新 更多