-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
47 lines (43 loc) · 1.21 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./dist/mvvm.js"></script>
</head>
<body>
<div id="app">
<strong>case 1: v-model 双向绑定</strong><br>
<input type="text" v-model="message">
<p>message: {{message}}</p>
<strong>case 2: v-text 单向绑定</strong>
<p v-text="message"></p>
<strong>case 3: \{\{'message: ' + message}} 单向绑定</strong><br>
<p>{{'message: ' + message}}</p>
<strong>case 4: \{\{info.a}} 单向绑定 可以通过控制台vm.info.a来改变</strong><br>
<p>info.a: {{info.a}}</p>
<strong>case 5: 事件绑定</strong><br>
<p>number: {{number}}</p>
<button @click="handleClick">number++</button>
</div>
<script>
let vm = new MVVM({
el: '#app',
data: {
message: 'hello world',
number: 0,
info: {
a: 'this is info.a'
}
},
methods: {
handleClick: function () {
this.number++;
}
}
});
</script>
</body>
</html>