我有一个 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/