我遇到了一个奇怪的问题,即视图中的某些“fireEvent”在我的 sencha 应用程序构建生产后不会起作用。在构建之前,一切正常,动作会按预期进行,但是,在构建生产之后,我发现'this'触发的'fireEvent'是正常的,但变量是不正常的。以下是我的代码。
Ext.define('WirelessCity.view.TopMenu', {
extend:'Ext.Toolbar',
alias:'widget.topmenu',
initialize: function(){
this.callParent(arguments);
var topMenu = this;
var btn = {
xtype: 'button',
width: 42,
margin: '5 0 5 3',
border: '0',
style: 'background:url(resources/images/left_btn.png);',
handler: this.onMarkButtonTap, // will work
scope: this
};
var search = {
width: 46,
margin:'3 5 0 0',
style:'background:url(resources/images/search_btn.png);border:0;background-repeat:no-repeat;',
initialize: function(){
this.element.on({
tap: function(){
topMenu.fireEvent('searchCmd', topMenu); // will not work
}
});
}
}
this.add([btn, search]);
},
config: {
docked: 'top',
//flex: 1,
height: 38,
padding: 0,
margin: 0,
border: 0,
style: 'background:url(resources/images/top.png)'
},
onMarkButtonTap: function(){
//Ext.Msg.alert('mark');
this.fireEvent('markCmd', this);
}
});