所以我试图将项目动态地放置到具有slidenavigation
特征:
// FlyoutNavigation.js
Ext.define("APN.view.FlyoutNavigation", {
id: "flyoutNavigationPanel",
extend: 'Ext.ux.slidenavigation.View',
这里是初始化view
另一种观点是:
// MainViewContainer.js
this.home = "Some var"
this.flyout = Ext.create('APN.view.FlyoutNavigation', {
id: 'flyoutNavigationPanel',
home: this.home
});
比我尝试在中使用这个变量this.config.items
部分,但是这不起作用,似乎 Sencha 首先编译所有内容,然后初始化组件,我可能是错的,我对 Sencha 框架真的很陌生。
所以这是视图home
使用变量:
Ext.define("APN.view.FlyoutNavigation", {
id: "flyoutNavigationPanel",
extend: 'Ext.ux.slidenavigation.View',
xtype: 'flyoutnavigation',
requires: [
... heaps of things omitted ...
],
initialize: function () {
this.callParent();
this.setupDynamicItems();
},
config: {
items: [
{
itemId: 'nav_home',
id: 'homeView',
items: [{
xtype: 'articlelist',
id: 'latestNews',
feedUrlName: this.home, // - that's the place where UNDEFINED occurs
flex: 1
}
],
},
So this.home
未定义...
一种可能的解决方案来自这个问题:如何在 Sencha Touch 中动态创建 xtype 模板 https://stackoverflow.com/questions/16622319/how-to-dynamically-create-xtype-templates-in-sencha-touch
我决定将所有代码放入this.config.items.add({ ... my items ... })
然而Ext.ux.slidenavigation.View
看来给我带来了BUG! :( 因为初始化方法发生在项目的绑定方法之后FlyoutNavigation
view.
以下是该错误的消息:Uncaught TypeError: Cannot read property 'raw' of undefined View.js:310
这基本上就是这一行:if (Ext.isFunction(item.raw.handler)) {
所以我的问题是
- 如何获取config.items部分中的实例变量?如果可以的话,那么一切都好
- 或者您知道这个问题的解决方法吗?
Thanks