标签:
先看代码
Ext.define("PSI.Sale.WSMainForm", {
extend: "Ext.panel.Panel",
border: 0,
layout: "border",
initComponent: function () {
var me = this;
//下面的代码略
1、上面的代码的主要含义是定义了一个新的class:PSI.Sale.WSMainForm,其父类是:Ext.panel.Panel
2、今天的新知识点是:initComponent
如果想给UI中增加新的组件,在initComponent中写代码就是必须了。所以在PSI的很多JS代码中,在initComponent中有大段的代码,也就是标配了。
Ext.apply
在initComponent中常用Ext.apply这个方法,例如:
Ext.apply(me, {
tbar: [{
text: "新建销售退货入库单",
iconCls: "PSI-button-add",
scope: me,
handler: me.onAddSRBill
}, "-", {
text: "编辑销售退货入库单",
iconCls: "PSI-button-edit",
scope: me,
handler: me.onEditSRBill
}
// 下面的代码略
通俗地讲,Ext.apply方法是向一个对象增加属性,再例如:
var a = {name: ‘PSI‘, age: 30};
Ext.applay(a, {age: 40, region: ‘Dalian‘});
// a => {name: ‘PSI‘, age: 40, region: ‘Dalian‘}
合并的原则就是:已有的属性被新的值覆盖,新增的属性就添加进来。
标签:
原文地址:http://my.oschina.net/u/134395/blog/476056