在我的应用程序中,我有一个带有一个项目的视口(viewport),一个主视图,它是一个从 Ext.container.Container 扩展的简单类。
我也有一个主 Controller ,我正在尝试获取 View 实例,因此无论用户是否登录,我都可以动态地推送相应的项目。
我尝试过使用 View :['MainView']、refs[ { selector: 'thextype' }] 等,但没有成功。
我在 sencha touch 中使用引用 (ref) 来做这种事情,你能帮我用 Extjs v4.2 吗?
为了澄清起见,我不是要获取 DOM 元素,而是要获取具有关联方法的 View 实例。
提前致谢
最佳答案
定义 View 的 xtype:
xtype: 'mainview'
然后在你的 Controller 中:
requires: ['...'] // your view class
// ...
refs: [{
ref: 'mainView',
selector: 'mainview' // your xtype
}]
然后您可以使用 this.getMainView()
关于ExtJS 4.2.1 - 无法从 Controller 获取 View 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17974565/