Posted on 2008-02-11 11:35
oxl 閱讀(442)
評論(0) 編輯 收藏 所屬分類:
技術感語
1 // 定義一個模塊,你可以像使用類一樣使用它,你完全可以把它當成是類。
2 // 它利用js的一些特性實現私有和公有,就和applayout.js中定義的名命空間一樣。
3 var module = function() {
4 // 私有變量
5 var message = 'Hello, Ext 2 beginner.';
6
7 // 公用變量或函數
8 return {
9 name: 'oxl',
10 init: function() {
11 message += this.name;
12 },
13
14 show: function() {
15 this.other();
16 alert(message);
17 },
18
19 other: function() {
20 alert('Welcome to Ext 2\'s world.');
21 }
22 };
23 }();