mootools1.5.1ノートの使用:クラスの作成、継承、既存のクラスの新しいメソッドの追加
4204 ワード
1 window.addEvent('domready',function(){
2 /*
3 Person , name sayHello ;
4 */
5 var Person= new Class({
6 initialize: function(name){
7 this.name = name;
8 },
9 sayHello:function(){
10 console.log('hello,my name is '+this.name);
11 }
12
13 });
14
15 // Sperman , Person
16 var Sperman=new Class({
17 Extends:Person,
18 initialize:function(name,age){
19 this.parent(name);
20 this.age=age;
21 },
22 });
23 // Dog sayWang
24 Sperman.implement({
25 sayAll:function(){
26 console.log(this.name+' is '+this.age+' years old...');
27 }
28 });
29 var Sperman=new Sperman('ollie',27);
30 Sperman.sayHello();//consolo.log hello,my name is ollie
31
32 Sperman.sayAll();//console.log ollie is 27 years old...
33 });