How to do a self-destroy inside a custom component in Sencha Touch

后端 未结 1 1641
臣服心动
臣服心动 2021-01-26 02:37

update:

new code:

Ext.define(\'Fiddle.MyCmp\',{
     extend:\'Ext.Component\'
    ,alias:\'widget.mycmp\'
    ,config:{
         html:\'MyCmp\'
    }
            


        
相关标签:
1条回答
  • 2021-01-26 03:15

    I suppose you want to destroy the component 5s after it is initialized. If so, the following code does it:

    Ext.define('Fiddle.MyCmp',{
         extend:'Ext.Component'
        ,alias:'widget.mycmp'
        ,config:{
             html:'MyCmp'
        }
        ,destroy:function() {
            console.log('destroy override');
            this.callParent(arguments);
        }
        ,initialize:function() {
            var me = this;
            Ext.Function.defer(function(){
                console.log('Destroying after delay')
                me.destroy();
            }, 5000, me);
        }
    });
    
    Ext.application({
        name : 'Fiddle',
        ref:{
            cmp: 'mycmp'
    
        },
    
        launch : function() {
            Ext.Viewport.add({
                xtype:'mycmp'            
            });        
        }
    })
    
    0 讨论(0)
提交回复
热议问题