EXT JS无法从其他.js获取定义

时间:2013-12-08 06:30:26

标签: javascript extjs

vehicle.js

var  BtnEdit = Ext.getCmp('BtnEdit');
    BtnEdit.on('click', function(){ 
        var grid = Ext.getCmp('mygridpanel')
        if (grid.getSelectionModel().hasSelection()) {
           var row = grid.getSelectionModel().getSelection()[0];
           console.log(row.get('Plat_No'));
        };

        var win = Ext.create('MyApp.view.Edit2');
        win.show();
    });

design.js

//==========================Edit Vehicle================================    
    Ext.define('MyApp.view.Edit2', {
    extend: 'Ext.window.Window',

    height: 218,
    id: 'ChangePasswordWin',
    width: 405,
    title: 'Edit',

    initComponent: function() {
        var me = this;

        Ext.applyIf(me, {
            items: [
                {
                    xtype: 'container',
                    height: 193,
                    width: 515,
                    layout: {
                        align: 'center',
                        type: 'hbox'
                    },
                    items: [
                        {
                            xtype: 'container',
                            flex: 1,
                            margins: '',
                            height: 145,
                            padding: '10 10 10 10',
                            width: 393,
                            layout: {
                                type: 'vbox'
                            },
                            items: [
                                {
                                    xtype: 'form',
                                    flex: 1,
                                    margins: '10 10 10 10',
                                    height: 152,
                                    width: 354,
                                    bodyPadding: 10,
                                    header: false,
                                    title: 'My Form',
                                    items: [
                                        {
                                            xtype: 'textfield',
                                            disabled: true,
                                            padding: '0 0 10 0',
                                            width: 320,
                                            fieldLabel: 'Vehicle ID',
                                            labelWidth: 150
                                        },
                                        {
                                            xtype: 'textfield',
                                            padding: '0 0 10 0',
                                            width: 320,
                                            fieldLabel: 'Plat Number',
                                            labelWidth: 150
                                        }
                                    ]
                                }
                            ]
                        }
                    ]
                }
            ],
            dockedItems: [
                {
                    xtype: 'toolbar',
                    dock: 'top',
                    items: [
                        {
                            xtype: 'button',
                            cls: '',
                            width: 59,
                            icon: '',
                            iconCls: 'save',
                            text: 'Save'
                        }
                    ]
                }
            ]
        });

        me.callParent(arguments);
    }

});

的index.html

<script type="text/javascript" src="vehicle.js"></script>
<script type="text/javascript" src="../resources/js/design.js"></script>

这是萤火虫日志

GET http://localhost/BusTicket/vehicle/MyApp/view/Edit2.js?_dc=1386481666308

404 Object Not Found
        0ms 
ext-all.js (line 27)
TypeError: c is not a constructor


...f(p==k){if(a+E+l.width>(O>=0?u.x+u.width-b:b-u.x)){p=M}}else{if(a+E>l.width){p=k...

我怎么得到这个错误?

1 个答案:

答案 0 :(得分:0)

我建议你:

1.-使用与您的班级相同的名称命名您的文件。

2. - 然后在你的app.js(或你称之为的任何东西)中,在相应的数组声明中添加你的视图文件。

Ext.application({
    ...
    models: ['Station', 'Song'],
    stores: ['Stations', 'RecentSongs', 'SearchResults'], 
    views: ['Edit2']
    ...
});

或者你也可以要求它:

  requires: [
        'MyApp.view.Edit2',
        'Panda.view.NewStation',
        'Panda.view.SongControls',
        'Panda.view.StationsList',
        'Panda.view.RecentlyPlayedScroller',
        'Panda.view.SongInfo'
    ],

http://docs.sencha.com/extjs/4.2.1/#!/guide/mvc_pt2

最诚挚的问候。