Sencha touch 在sencha touch中切换卡
在本例中,我不太清楚更改卡片的语法。我试着给小组打了一个裁判,但没有成功。我想使用底部的onButton功能切换卡片,该功能由submit按钮触发(只是一个按钮,在本例中并不真正用作表单)Sencha touch 在sencha touch中切换卡,sencha-touch,sencha-touch-2,Sencha Touch,Sencha Touch 2,在本例中,我不太清楚更改卡片的语法。我试着给小组打了一个裁判,但没有成功。我想使用底部的onButton功能切换卡片,该功能由submit按钮触发(只是一个按钮,在本例中并不真正用作表单) 提前感谢您是否尝试了此.main.setActiveItem(1)内部onButton()方法 如果你想通过这个“开关”按钮切换卡片,你可以设置一个变量,比如说this.activeItemNo=0在“launch”方法内,并在onButton方法内使用if-else条件。希望这能有所帮助。结果表明,ST d
提前感谢您是否尝试了
此.main.setActiveItem(1)代码>内部onButton()方法
如果你想通过这个“开关”按钮切换卡片,你可以设置一个变量,比如说this.activeItemNo=0代码>在“launch”方法内,并在onButton方法内使用if-else条件。希望这能有所帮助。结果表明,ST dev preview 2中有一个bug。作用域未正确传递给onButton函数。预期的切换方式是.main.setActiveItem(),由于此问题,它对我不起作用。现在的范围可以在控制方法中传递:
Ext.application({
name: 'Sencha',
main: null,
refs: [
{
ref: "main",
selector: "mypanel"
}
],
init: function() {
this.control({
'#switch': {
tap: this.onButton
},
}, null, this) //this is what is needed
},
launch: function() {
this.main = Ext.create("Ext.Panel", {
fullscreen: true,
layout: 'card',
xtype: 'mypanel',
items: [
{
title: 'Home',
iconCls: 'home',
cls: 'home',
html: 'home page',
},
{
title: 'Contact',
iconCls: 'user',
xtype: 'formpanel',
url: 'contact.php',
layout: 'vbox',
items: [
{
xtype: 'fieldset',
title: 'Contact Us',
instructions: '(email address is optional)',
items: [
{
xtype: 'textfield',
label: 'Name'
},
{
xtype: 'emailfield',
label: 'Email'
},
{
xtype: 'textareafield',
label: 'Message'
}
]
},
{
xtype: 'button',
itemId: 'switch',
id: 'switch',
text: 'Send',
ui: 'confirm',
}
]
}
]
});
this.main.setActiveItem(1);
},
onButton: function() {
this.main.setActiveItem(0);
}
});
您是否尝试过Ext.getCmp('componentId').setActiveItem(1)代码>
当然,您需要为主面板分配一个id
你有什么错误吗?你能检查一下console.log9this.main)内部的onButton方法吗?
Ext.application({
name: 'Sencha',
main: null,
refs: [
{
ref: "main",
selector: "mypanel"
}
],
init: function() {
this.control({
'#switch': {
tap: this.onButton
},
}, null, this) //this is what is needed
},
launch: function() {
this.main = Ext.create("Ext.Panel", {
fullscreen: true,
layout: 'card',
xtype: 'mypanel',
items: [
{
title: 'Home',
iconCls: 'home',
cls: 'home',
html: 'home page',
},
{
title: 'Contact',
iconCls: 'user',
xtype: 'formpanel',
url: 'contact.php',
layout: 'vbox',
items: [
{
xtype: 'fieldset',
title: 'Contact Us',
instructions: '(email address is optional)',
items: [
{
xtype: 'textfield',
label: 'Name'
},
{
xtype: 'emailfield',
label: 'Email'
},
{
xtype: 'textareafield',
label: 'Message'
}
]
},
{
xtype: 'button',
itemId: 'switch',
id: 'switch',
text: 'Send',
ui: 'confirm',
}
]
}
]
});
this.main.setActiveItem(1);
},
onButton: function() {
this.main.setActiveItem(0);
}
});