-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdemo6.html
60 lines (51 loc) · 1.3 KB
/
demo6.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ES6继承</title>
</head>
<body></body>
</html>
<script>
class KFC {
constructor(food) {
this.food = food;
}
getFood() {
console.log(this.food);
}
}
class Mcdonalds extends KFC {
constructor(food, newFood) {
super(food);
this.newFood = newFood;
}
getNewFood() {
console.log(this.newFood);
}
}
const dog = new Mcdonalds("老北京鸡肉卷", "5G炸鸡");
dog.getFood(); // "老北京鸡肉卷"
dog.getNewFood(); // "5G炸鸡"
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
var Mcdonalds = /*#__PURE__*/ (function (_KFC) {
_inheritsLoose(Mcdonalds, _KFC);
var _super = _createSuper(Mcdonalds);
function Mcdonalds(food, newFood) {
var _this;
_this = _KFC.call(this, food) || this;
_this.newFood = newFood;
return _this;
}
var _proto2 = Mcdonalds.prototype;
_proto2.getNewFood = function getNewFood() {
console.log(this.newFood);
};
return Mcdonalds;
})(KFC);
</script>