-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
38 lines (36 loc) · 907 Bytes
/
index.html
File metadata and controls
38 lines (36 loc) · 907 Bytes
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>构造方法最终版本</title>
<link rel="stylesheet" href="">
</head>
<body>
<script>
function Dog(Option){
this._init(Option);
};
//通过构造函数调用prototype的方法,动态的向构造函数中添加属性或者方法。
Dog.prototype = {
_init: function(Option){
this.name = Option.name;
this.age = Option.age;
this.sex = Option.sex;
},
Walk: function(SomeWhere){
console.log(this.name + "正在" + SomeWhere);
},
Eat: function(SomeThing){
console.log(this.name + "正在吃" + SomeWhere);
},
Sleep: function(){
console.log(this.name + "正在睡觉");
}
};
var smallDog = new Dog({name: "小花", age: 15, sex: "gril"});
smallDog.Walk("人民广场");
</script>
<h1>我是标题</h1>
</body>
</html>