我正在尝试学习 ExtJS 5,并且已经遇到了一个问题,试图将我的 UI 分割成适当的视图和视图控制器。我的应用程序包含一个文件,其边框布局分为三个部分。我想把每个部分变成一个单独的模块,但我不确定这样做的正确方法。我尝试简单地添加一个控制器和视图,并将项目的 xtype 更改为视图的 xtype,但我只是得到一个空面板。
边框布局的“南”部分是我试图移动到它自己的控制器开始的部分。
这是我的应用程序的精简版:
Ext.define('RpgInfoSystem.Application', {
extend: 'Ext.app.Application',
name: 'RpgInfoSystem',
launch: function() {
Ext.create('Ext.container.Viewport', {
layout: 'border',
bodyBorder: false,
defaults: {
collapsible: true,
split: true,
bodyPadding: 5
},
// Here is where we require our modules
//requires: ['RpgInfoSystem.Reference.controller.Reference'],
// Here is where we insert our modules into the UI
items: [{
region: 'north',
xtype: 'component',
collapsible: false,
resizeable: false,
floatable: false,
padding: 0,
margin: 0,
height: 25,
minHeight: 25,
maxHeight: 25,
html: '<h1 style="margin: 0; padding: 0;">RPG Information System</h1>'
}, {
xtype: 'tabpanel',
collapsible: false,
region: 'center',
margin: '5 0 0 0',
items: [{
title: 'Initiative Tracker',
html: '<h2>Main Page</h2><p>This is where the main content will go. For players, this will be their character sheets. For the DM, this will be the initiative tracker.</p>'
}, {
title: 'Templates',
html: 'Templates for NPCs and enemies, which can be copied into the initiative tracker.'
}]
}, {
title: 'Utilities',
xtype: 'panel',
region: 'east',
floatable: false,
margin: '5 0 0 0',
width: 300,
minWidth: 100,
//maxWidth: 250,
layout: {
type: 'vbox',
pack: 'start',
align: 'stretch'
},
items: [{
title: 'Campaign Info',
xtype: 'tabpanel',
flex: 1,
margin: '0 0 1 0',
items: [{
title: 'Session',
html: 'A text area to enter notes for the campaign and scroll through other users\'s notes.'
}, {
title: 'Campaign',
html: 'Information about the current campaign, as well as the ability to take and edit notes.'
}
]
}]
}, {
title: 'Reference',
xtype: 'mycustomview', //HERE IS WHERE I AM CUSTOMIZING
region: 'south',
floatable: false,
height: 250,
minHeight: 150,
collapsed: true,
}]
});
}
});
还有我的发射器:
Ext.application({
name: 'RpgInfoSystem',
extend: 'RpgInfoSystem.Application',
controllers: [
'Reference'
]
});