代码之家  ›  专栏  ›  技术社区  ›  Harikrishnan

无法从Ext.navigation.view[object Window]推送新视图没有方法“up”

  •  0
  • Harikrishnan  · 技术社区  · 12 年前

    我在推送时得到了这个错误。

    Uncaught TypeError: Object [object Window] has no method 'up' 
    

    我的代码

    Ext.define('Proj.view.test.Home', {
        extend: 'Ext.navigation.View',
        xtype: 'homeTabItem',
        id: 'home',
    
        requires : [],
        config: {
            refs:{
                homeTab:'homeTabItem'
            },
            title : 'Home',
            iconCls: 'home',
            scrollable:true,
            listeners  : {
                element  : 'element',
                scope : this,
                delegate : 'div',
                tap      : function(e) {
                    e.stopEvent();
                    console.log(e.target.id);
                    this.up('homeTabItem').push({
                            xtype: 'newView'
    
                     });
                }
            }
        },
    
        initialize:function(){
            Ext.Ajax.request({
                url: 'test.html',
                method: 'GET',
                callback: function(options, success, response) {
                    Ext.ComponentQuery.query('homeTabItem')[0].setHtml( response.responseText );
                }
            });
        }
    
    })
    
    1 回复  |  直到 12 年前
        1
  •  1
  •   Titouan de Bailleul    12 年前

    创建全局变量

    var myThis;
    

    在初始化中添加 myThis=this;

    现在您可以使用myThis来推送视图

    推荐文章