-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex2.html
51 lines (44 loc) · 1.32 KB
/
index2.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
<!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="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
<div id="app">
<p>{{ foo }}</p>
<!-- 这里的 `foo` 不会更新! -->
<button v-on:click="foo = 'baz'">Change it</button>
</div>
<script>
var obj = {
foo: "bar",
};
Object.freeze(obj);
new Vue({
el: "#app",
data: obj,
});
var data = { a: 1 };
var vm = new Vue({
el: "#example",
data: data,
});
vm.$data == data;
vm.$el == document.getElementById("example");
vm.$watch("a", function (newValue, oldValue) {});
new Vue({
data: {
a: 1,
},
created: function () {
// `this` 指向 vm 实例
console.log("a is: " + this.a);
},
});
</script>
</body>
</html>