首页 > 解决方案 > ExtJs 工具栏配置对象

问题描述

所以我在我的主视图中有以下场景我有一个这样的容器:

Ext.define('APP.view.main.Main', {
extend: 'Ext.container.Container',
xtype: 'app-main',
id: 'root',
requires: [
    'Ext.menu.*'
],
items:[
    'APP.view.main.topBar'
    ]
});

我的 APP.view.main.topBar 看起来像这样:

Ext.define('APP.view.main.topBar',{

extend: 'Ext.container.Container',
docked: 'top',
xtype: 'toolbar',
id: 'topBar',
title: 'Meniu',

items:[
    {
        text: 'Furnizori',
        iconCls: 'x-fa fa-qrcode',
        menu: 'APP.view.main.menus.menuFurn'
        }

    ]
});

问题是我收到以下错误:

Invalid config, must be a valid config object

我正在尝试将工具栏包含在主要项目中

标签: javascriptextjs

解决方案


主类中的项目需要是一个适当的对象。见下文:

Ext.define('APP.view.main.topBar', {

    extend: 'Ext.container.Container',
    docked: 'top',
    xtype: 'myAppTopBar',
    id: 'topBar',
    title: 'Meniu',

    items: [{
            text: 'Furnizori',
            iconCls: 'x-fa fa-qrcode',
            menu: 'APP.view.main.menus.menuFurn'
        }

    ]
});

Ext.define('APP.view.main.Main', {
    extend: 'Ext.container.Container',
    xtype: 'app-main',
    id: 'root',
    requires: [
        'Ext.menu.*'
    ],
    items: [{
        xtype: 'myAppTopBar'
    }]
});

推荐阅读