例1
优化了一下代码,结果如下。
调用:
代码如下 | 复制代码 |
组件定义
代码如下 | 复制代码 |
Ext.define('WX.student.AddStudent', { modal:true, }); |
例2
新件一个JS文件
代码如下 | 复制代码 |
// JavaScript Document 编号:{ID} ',' 姓名:{FirstName}-{LastName} ',' 电话:{Phone} ',' 城市:{City} ',' 邮箱:{Email} ']), initComponent:function(){ CRM.Panels.UserDetail.superclass.initComponent.call(this); if(typeof this.tpl === 'string'){ this.tpl = new Ext.XTemplate(this.tpl); } this.addEvents('UAlert');//注册新事件 this.addListener({//侦听函数 UAlert: { //注册的新事件 fn:this.onAlert,//调用onAlert方法 scope: this } }); }, ////////////// onAlert: function(){ alert('注册的新事件'); }, UAlert:function(){ this.fireEvent('UAlert'); }, ///////////////////// onRender: function(ct, position){ CRM.Panels.UserDetail.superclass.onRender.call(this, ct, position); if(this.data){ this.update(this.data); } }, update: function(data){ this.data = data; this.tpl.overwrite(this.body, this.data); // this.fireEvent('update',this.data); } }); //把新建的自定义组件注册为一种xtype
|
在页面上:
代码如下 | 复制代码 |
|