【发布时间】:2012-12-31 10:48:11
【问题描述】:
点击工具栏中的“登录”时,我正在尝试切换面板。 我的控制器收到事件,我通过添加活动项目并将其设置到我想要的面板进行切换。但是,屏幕保持空白(并且没有调试错误)。
这是我面板的代码,知道可能是什么错误吗?
Ext.define('App.view.LoginView', {
extend: 'Ext.Panel',
xtype: 'loginpanel',
alias: 'widget.loginView',
fullscreen: true,
layout: 'fit',
items: [
{
xtype: 'TopToolBar'
},
{
xtype: 'formpanel',
items: [
{
xtype: 'fieldset',
title: 'Login',
instructions: 'Have a great day!',
items: [
{
xtype: 'emailfield',
name: 'email',
label: 'Email'
},
{
xtype: 'passwordfield',
name: 'password',
label: 'Password'
}
]
},
{
xtype: 'button',
text: 'Login',
ui: 'confirm',
handler: function()
{
this.up('loginpanel').submit();
}
}
]
}]})
我的工具栏类的代码:
Ext.define('App.view.TopToolBar', {
extend: 'Ext.Toolbar',
xtype: 'TopToolBar',
dock: 'top',
initialize: function() {
var loginButton = {
xtype: 'button',
text: 'Login',
ui: 'action',
handler: this.onLoginTap,
scope: this
};
this.add(loginButton);
},
onLoginTap: function(){
console.log('login tap');
this.fireEvent('loginBtnHandler', this);
}})
【问题讨论】:
-
什么时候黑屏?当您按下按钮或尝试执行代码时?看起来您只定义类而不实例化它们。
-
确实,这就是问题所在,我没有实例化它们;)谢谢! (我还必须为组件提供布局)
-
我应该回答这个问题以便您接受吗?它对你、这个网站和我来说都更好:)