控制台错误:无法识别的别名:widget.feedform

Error in console: Unrecognized alias: widget.feedform

我有以下问题。当我按下 feeds.js 文件夹中的 Add New Feed 按钮时,它应该调用 onNewFeed 函数(位于 MainController.js文件),控制台出现错误:

Unrecognized alias: widget.feedform

当我在 文件中添加 MainController.js 时需要:['FeedViewer.view.main.FeedForm'] 控制台显示:

[Ext.Loader] error Some requested files failed to load.

文件夹结构:

//FeedViewer
    //app
        //view
           //main
               /MainController.js
               /MainModel.js
    //classic
    //modern
        //src
            //view
                //main
                    /FeedForm.js
                    /Feeds.js
                    /Main.js

MainController.js

Ext.define('FeedViewer.view.main.MainController', {
    extend: 'Ext.app.ViewController',
    alias: 'controller.main',

    onNewFeed: function () {
        var navView = this.getView(),
            form = navView.child('feedform');

        if (!form) {
            navView.push({
                xtype: 'feedform',
                reference: 'feedform'
            });
        } else {
            navView.setActiveItem(form);
        }
    }
});

FeedForm.js

Ext.define('FeedViewer.view.main.FeedForm', {
    extend: 'Ext.form.Panel',
    xtype: 'feedform',

    requires: [
        'Ext.Button',
        'Ext.field.Select',
        'Ext.form.FieldSet',
        'Ext.Toolbar'
    ],

    title: 'New RSS Feed',

    items: [{
        xtype: 'fieldset',
        items: [{
            xtype: 'selectfield',
            label: 'Select a new feed',
            labelAlign: 'top',
            allowBlank: false,
            name: 'feedUrl',
            options: [{
                value: 'http://rssfeeds.usatoday.com/usatoday-NewsTopStories', 
                text: 'USA Today Top Stories'
            }, {
                value: 'http://sports.espn.go.com/espn/rss/news', 
                text: 'ESPN Top News'
            }]
        }]
    }, {
        xtype: 'toolbar',
        docked: 'bottom',
        items: [{
            xtype: 'button',
            reference: 'savebutton',
            action: 'save',
            ui: 'action',
            text: 'Add'
        }]
    }]
}); 

Feeds.js

Ext.define('FeedViewer.view.main.Feeds', {
    extend: 'Ext.grid.Grid',

    xtype: 'feedslist',

    requires: [
        'ContactsApp.view.feeds.MainController',
        'ContactsApp.view.feeds.MainModel'

    ],

    viewModel: 'feeds',
    controller: 'feeds',

    columns: [{
        dataIndex: 'feed',
        text: 'feed'
    }],

    items: [{
        xtype: 'toolbar',
        docked: 'left',
        items: [{
            xtype: 'button'
            text: 'Add New Feed',
            iconCls: 'fa fa-plus',
            listeners: {
                click: 'onNewFeed'
            }
        }]
    }]
});

Main.js

Ext.define('FeedViewer.view.main.Main', {
    extend: 'Ext.tab.Panel',
    xtype: 'app-main',

    requires: [
        'Ext.window.MessageBox',

        'FeedViewer.view.main.MainController',
        'FeedViewer.view.main.MainModel',
        'FeedViewer.view.main.List'
    ],

    controller: 'main',
    viewModel: 'main',
    layout: 'column',

    items: [{
        xtype: 'feedlist',
        columnWidth: 0.5
    }]
});

Ext 试图动态加载一个组件,似乎 feedform 没有正确注册。


你试过添加

alias: 'widget.feedform',

给你的FeedForm.js


Panel.js 作为对比:

https://docs.sencha.com/extjs/6.2.0/classic/src/Panel.js.html