1 /* 2 *tpl模版加入按钮 3 *4 *fire="tasteUp" 表示添加tasteUp事件和激活dotasteUp方法 5 *有两个参数cmp:视图本身以及doit 6 *只要是以上格式的模板都可以被监控到 7 *其中btn、shareIco为自定义样式,其他都是st自带样式 8 */ 9 Ext.define('ux.plugin.ConTpl', {10 alias: 'plugin.conTpl',11 xtype: 'conTpl',12 config: {13 cmp: null,14 //按下时添加css15 pressedCls: 'pressing',16 //监控对象选择器17 delegate: 'div.fire'18 },19 constructor: function (config) {20 this.initConfig(config);21 this.callParent([config]);22 },23 //初始化24 init: function (cmp) {25 this.setCmp(cmp);26 },27 //更新配置28 updateCmp: function (newCmp, oldCmp) {29 if (newCmp) {30 newCmp.on({31 //只有创建完成后才能监听事件32 render: 'onRender',33 scope: this34 });35 }36 },37 //创建完成38 onRender: function (t, eOpts) {39 t.el.on({40 click: 'onTap',41 delegate: this.getDelegate(),42 scope: this43 });44 },45 //执行动作46 onTap: function (e) {47 var cmp = this.getCmp(),48 el = e.getTarget(this.getDelegate(), null, true),49 fire = el.getAttribute('fire');50 cmp.fireEvent(fire, cmp, el);51 }52 });