xxxxxxxxxx
1
odoo.define("myfirstwidget_test_js",function (require) {
2
"use strict";
3
var Class = require('web.Class');
4
5
var Animal = Class.extend({
6
init: function () {
7
this.x = 0;
8
this.hunger = 0;
9
},
10
move: function () {
11
this.x = this.x + 1;
12
this.hunger = this.hunger + 1;
13
},
14
eat: function () {
15
this.hunger = 0;
16
},
17
});
18
return Animal
19
});
20
//
21
odoo.define("myfirstwidget_test2_js",function (require) {
22
"use strict";
23
var Animal = require('myfirstwidget_test_js');
24
var Dog = Animal.extend({
25
move: function () {
26
this.bark();
27
this._super.apply(this, arguments);
28
},
29
bark: function () {
30
console.log('woof');
31
},
32
});
33
var dog = new Dog();
34
dog.move()
35
});
36
37
odoo.define("myfirstwidget_test3_js",function (require) {
38
"use strict";
39
var Animal = require('myfirstwidget_test_js');
40
var DanceMixin = {
41
dance: function () {
42
console.log('dancing...');
43
},
44
};
45
46
var Hamster = Animal.extend(DanceMixin, {
47
sleep: function () {
48
console.log('sleeping');
49
},
50
});
51
var ham = new Hamster();
52
ham.sleep();
53
ham.dance();
54
return Hamster
55
});
56
57
58
odoo.define("myfirstwidget_test4_js",function (require) {
59
"use strict";
60
var Hamster = require('myfirstwidget_test3_js');
61
Hamster.include({
62
sleep: function () {
63
this._super.apply(this, arguments);
64
console.log('zzzz');
65
},
66
});
67
var ham = new Hamster();
68
ham.sleep();
69
ham.dance();
70
});
已复制