Sencha extjs 5在West布局中显示树

Sencha extjs 5 displaying tree in West layout

本文关键字:显示 布局 West extjs Sencha      更新时间:2023-09-26

我使用的是Sencha extjs 5。我在西部布局中加载树菜单时遇到问题。我似乎什么都展示不了。请协助。

这是我的Main.js代码:

items: [
    {
        title: 'Navigation',
        region:'west',
        floatable: false,
        margin: '5 0 0 0',
        width: 200,
        minWidth: 100,
        maxWidth: 350,
        html: '<script type="text/javascript" src="app/view/app.js"></script>'
    }

这是我的app.js代码:

Ext.create('Ext.tree.Panel', {
renderTo: 'west',
title: 'Simple Tree',
width: 300,
height: 250,
root: {
    text: 'Root',
    expanded: true,
    children: [{
        text: 'Child 1',
        leaf: true
    }, {
        text: 'Child 2',
        leaf: true
    }, {
        text: 'Child 3',
        expanded: true,
        children: [{
            text: 'Grandchild',
            leaf: true
        }]
    }]
}
});

如果使用renderTo,则不使用regionregion仅在将组件添加到具有边框布局的容器中时使用。还有一点Ext.getBody()不接受任何参数,所以Ext.getBody('west')只返回页面的body元素。如果页面上有west id的元素(例如div),则使用renderTo: 'west'