2
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 中有这个组件,当我在测试环境中使用它时可以正常工作,但是一旦我构建项目,它就不会在构建版本中调用初始化函数,有人可以帮我解决这个问题。我已经尝试过用谷歌搜索这个问题,但没有用。

4

1 回答 1

1

覆盖时不要忘记调用父方法initialize

initialize: function (obj) {
    var me = this;
    me.callParent(arguments); 
    me.element.down('img').on('tap', me.imageTap, this, me);
}

而且我认为在这种情况下你不需要构造函数,因为总是调用初始化。

于 2014-04-25T15:39:02.110 回答