我有这个控制器:
Ext.define('MyApp.controller.Test', {
extend: 'Ext.app.Controller',
config: {
},
refs: [
{
ref: 'first',
selector: '#first'
},
{
ref: 'second',
selector: '#second'
}
],
views : [
'TestMain',
'TestSecond'
],
init: function() {
this.getTestMainView().create();
this.control({
'#first': {
tap: function() {
//how do I go to second view here?
}
},
'#second': {
tap: function() {
}
}
});
}
});
这两个视图:
Ext.define('MyApp.view.TestMain', {
extend: 'Ext.Container',
xtype: 'testmain',
config: {
fullscreen: true,
layout: 'vbox',
scrollable: true,
items: [
{
xtype: 'button',
ui: 'normal',
id: 'first',
text: 'Go To Second Screen',
handler: function() {
//how do I go to second view here?
}
}
]
}
});
...
Ext.define('MyApp.view.TestSecond', {
extend: 'Ext.Container',
xtype: 'testsecond',
config: {
fullscreen: true,
layout: 'vbox',
scrollable: true,
items: [
{
xtype: 'button',
ui: 'normal',
id: 'second',
text: 'Go To First Screen',
handler: function() {
}
}
]
}
});
我希望当我单击第一个按钮时加载第二个视图,反之亦然当我单击第二个按钮时加载。看来我可以在按钮处理程序或控制部分中添加代码 - 我希望能提供两者的示例(除非它们相同),并且可能解释哪种方法最好以及原因。
请注意,我不想使用卡片布局或选项卡面板 - 我想知道如何从一个独立视图切换到另一个独立视图(在我的应用程序中,我有一个卡片面板和一个选项卡面板,我需要使用按钮在两个组之间切换)
Thanks!!