【问题标题】:panel not showing sencha touch 2面板没有显示 sencha touch 2
【发布时间】: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);
}})

【问题讨论】:

  • 什么时候黑屏?当您按下按钮或尝试执行代码时?看起来您只定义类而不实例化它们。
  • 确实,这就是问题所在,我没有实例化它们;)谢谢! (我还必须为组件提供布局)
  • 我应该回答这个问题以便您接受吗?它对你、这个网站和我来说都更好:)

标签: extjs views touch panels


【解决方案1】:

使用Ext.define 定义类。

Ext.define('My.Toolbar', {
    extend: 'Ext.Toolbar',
    alias: 'widget.mytoolbar'
    //configuration
});

使用Ext.create 创建(实例化)类

var tlb= Ext.create('My.Toolbar', {
    //configuration
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多