-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
60 lines (60 loc) · 1.71 KB
/
index.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>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>mvvm 框架演示</title>
</head>
<style>
#app {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}
</style>
<body>
<h1>这是一个 MVVM 框架示例</h1>
<div id="app">
<div class="wrapper">
<h2>{{name}}</h2>
<label for="">
设置姓名
<input v-model="name" type="text">
</label>
<h2>{{age}}</h2>
<label for="">
设置年龄
<input v-model="age" type="text">
</label>
<div class="button">
<button v-on:click="addLife">点我+1s</button>
<button v-on:click="removeLife">点我-1s</button>
</div>
</div>
</div>
<script src="./src/observer.js" charset="utf-8"></script>
<script src="./src/subject.js" charset="utf-8"></script>
<script src="./src/common.js" charset="utf-8"></script>
<script src="./src/compiler.js" charset="utf-8"></script>
<script src="./src/mvvm.js" charset="utf-8"></script>
<script>
var vm = new Mvvm({
el: '#app',
data: {
name: '长者',
age: 90,
},
methods: {
addLife() {
this.age += 1;
},
removeLife() {
this.age -= 1;
}
},
});
alert(`目前${vm.name}的年龄是${vm.age}岁`);
</script>
</body>
</html>