javascript - 添加初始化函数时 Sencha xtype 导航失败

标签 javascript extjs sencha-touch-2

我有一个 Home.js View ,在底部栏中有一些用于子页面的嵌入式 xtype。首先,我在配置中添加了其他 View ,一切正常,但现在我需要使用 initalize 方法设置一些其他内容(即用户名)。

但是,现在不再触发到其他 View 的导航。没有任何反应,没有触发任何操作或任何错误。 View 仍然正确显示。

View

Ext.define('MyApp.view.Home', {
extend : 'Ext.tab.Panel',
id : 'home',
xtype : 'homeview',
requires : ['Ext.TitleBar', 'Ext.Video', 'MyApp.view.Profile'],

initialize : function() {

    console.log('Initializing Home');
    var me = this
    var config = me.getInitialConfig();
    var username = config.username;
    var items = [];

    items.push({
        xtype : 'titlebar',
        docked : 'top',
        title : 'Hello ' + username
    }, {
        xtype : 'updatesview',
    }, {
        xtype : 'searchview',
    }, {
        xtype : 'profileview'
    }, {
        xtype : 'messagesview'
    }, {
        xtype : 'sensesview'
    });

    me.setItems(items);

    console.log('Initializing Home');
},
config : {
    title : 'Home',
    iconCls : 'home',
    tabBarPosition : 'bottom'

}

});

切换回此作品(????)

旧 View ,只使用配置

Ext.define('MyApp.view.Home', {
extend : 'Ext.tab.Panel',
id : 'home',
xtype : 'homeview',
requires : ['Ext.TitleBar', 'Ext.Video', 'MyApp.view.Profile'],

config : {
    title : 'Home',
    iconCls : 'home',
    tabBarPosition : 'bottom',
    items : [{
        xtype : 'updatesview',
    }, {
        xtype : 'searchview',
    }, {
        xtype : 'profileview'
    }, {
        xtype : 'messagesview'
    }, {
        xtype : 'sensesview'
    }]
}

});

更新

我都试过了

me.setItems(items);
me.addItems(items);

没有效果。

更新 2

好的,问题出在初始化函数上。 ANY init 禁用导航(??)

initialize : function() {
    console.log('init home');
},

感谢您的帮助!

最佳答案

我认为你需要在你的 init 中调用父 init 方法:

...
initialize : function() {
  this.callParent(arguments);
  ...
  // Rest of your code...
},
...

关于javascript - 添加初始化函数时 Sencha xtype 导航失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15141000/

相关文章:

cordova - 收到错误消息 "Registering a component with a id (` form 1`) which has already been used"

sencha-touch - 如何使用 Sencha Touch 上传照片图像而无需手机间隙

javascript - 通过Web3访问智能合约成员功能

javascript - 如何根据 CFM 表单选择的值发送电子邮件

css - ExtJS 4.2 标题文本换行时如何设置网格过滤器高度?

javascript - 如何从 ExtJS5 中的存储中获取字段

javascript - 使用 ng-click 在函数中传递对象

javascript - IE6 中的绘图功能有多强大?

javascript - 在 Rally SDK 中,如何创建一个过滤器来测试配置类型子代的子代?

javascript - 如何在sencha touch 2中获取div的高度?