|
|
@@ -0,0 +1,41 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="en">
|
|
|
+
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>Document</title>
|
|
|
+</head>
|
|
|
+
|
|
|
+<body>
|
|
|
+ <script>
|
|
|
+ function Father(a) {
|
|
|
+ this.name = '图图';
|
|
|
+ this.list = ['吃饭', '睡觉', '打豆豆'];
|
|
|
+ this.address = a;
|
|
|
+ }
|
|
|
+ Father.prototype.say = function () {
|
|
|
+ console.log("你好");
|
|
|
+ }
|
|
|
+ function Child(val) {
|
|
|
+ Father.call(this,val);
|
|
|
+ }
|
|
|
+ // Child.prototype = new Father();
|
|
|
+
|
|
|
+ function createObj(c, f) {
|
|
|
+ c.prototype = Object.create(f.prototype);
|
|
|
+ c.prototype.constructor = c;
|
|
|
+
|
|
|
+ }
|
|
|
+ createObj(Child, Father)
|
|
|
+ let c1 = new Child('北京');
|
|
|
+ let c2 = new Child('哈尔滨');
|
|
|
+ c1.list.push("hahaha")
|
|
|
+ console.log(c1, 'c1');
|
|
|
+ console.log(c2, 'c2');
|
|
|
+ c1.say();
|
|
|
+ c2.say();
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+
|
|
|
+</html>
|