鏈綆鍗曠殑鏂瑰紡鏄嬌鐢ㄧ洿鎺ラ噺鐨勮娉曪紝瀹冮傚悎浜庡崟涓殑瀹炰緥錛屾瘮濡傛暣浣撳竷灞錛屾垨紿椾綋閮ㄤ歡銆備笉浣跨敤"new"鏉ュ垱寤恒?
aaa = {
ccc: "test",
bbb : function() { alert(this.cc); }
}
aaa.bbb();
濂藉鏄皟寮忕殑鏃跺欏彲浠ュ緢鏂逛究鐨勮闂唴閮ㄥ彉閲忋?br>
Class definitions with private variables
aaa = (function () {
var myprivate;
return {
setIt: function(val) { myprivate = val; }
getIt: function() { return myprivate; }
}
})();
鎴戠洰鍓嶇殑鐢ㄦ硶
function AAA() {
var myprivate;
this.setIt = function(val) { myprivate = val; }
this.getIt = function() {return myprivate; }
}
aaa = new AAA();
鍦╡xtjs涓紝榪欑鏂規硶鐨勪嬌鐢ㄥ緢鏅亶銆傚畠闄愬埗浜嗗縐佹湁鍙橀噺鐨勮闂紝涔熼犳垚璋冭瘯鐨勪笉渚褲?br>
Extending objects with Ext.extend
function MyCombo (config) {
// set up your datasource here..
MyCombo.superclass.constructor.call(this,config);
}
Ext.extend(MyCombo, Ext.form.ComboBox, {
displayField:'title',
typeAhead: true,
loadingText: 'Searching
',
forceSelection: true,
allowBlank: false,
width: 160,
minChars: 1,
pageSize:10,
hideTrigger:true,
displayField: 'FullName',
valueField: 'id'
}

]]>