initialize:不在生产版本中工作

时间:2014-04-23 16:49:20

标签: extjs sencha-touch sencha-touch-2 sencha-touch-2.3

xtype: 'component',
                        cls: 'headerComponent',
                        id: 'RequirementHeader' + i,
                        itemId: 'requirementHeaderViewID-' + i,
                        html: arrReqTplHeader,
                        constructor: function (config) {
                            var me = this,
                                currentConfig = me.config;
                            me.fireEvent('initialize', me);
                        },
                        initialize: function (obj) {
                            var me = this;
                            me.element.down('img').on('tap', me.imageTap, this, me);                            
                        }, imageTap: function (obj) {
                        alert("it doest reach here");
                        }

我在sencha touch中有这个组件,当我在测试环境中使用它时工作正常,但是一旦我构建项目它就不会在构建版本中调用initialize函数, 有人可以帮我这个。我已经尝试谷歌搜索问题,但没有用。

1 个答案:

答案 0 :(得分:1)

当您覆盖initialize

时,不要忘记调用父方法
initialize: function (obj) {
    var me = this;
    me.callParent(arguments); 
    me.element.down('img').on('tap', me.imageTap, this, me);
}

我认为在这种情况下你不需要构造函数,因为始终会调用initialize。