-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
61 lines (61 loc) · 1.49 KB
/
test.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
61
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="./dist/mini-vue.js"></script>
</head>
<body>
<div id="app">
<h3>{{title}}</h3>
<div>
<button v-on:click="print">显示/隐藏</button>
- <input type="text" v-model="msg"> - <b v-show="isShow">msg: {{msg}}</b></div>
<br>
<div>
people.name: <input type="text" v-model="people.name">
people.age: <input type="number" v-model="people.age">
</div>
<br>
<div> I am {{people.name}} , My age is {{people.age}}</div>
<br>
<p>computed greet: {{greet}}</p>
<p>arr value change by index: {{arrStr}}</p>
</div>
<script>
window.vm = new MiniVue({
el: '#app',
data: {
title: 'A mini Vue Framework',
msg: '123',
arr: [0, 1, 2],
isShow: true,
people: {
name: '张三',
age: 10
}
},
methods: {
print() {
this.isShow = !this.isShow;
}
},
watch: {
msg(newVal, oldVal) {
console.log('watch msg:', newVal, oldVal, this.title);
}
},
computed: {
greet: function () {
return `hello, I am ${this.people.name}, My age twice is ${this.people.age * 2}`;
},
arrStr: function () {
return this.arr.toString();
}
}
});
</script>
</body>
</html>