-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
54 lines (54 loc) · 1.4 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
<!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>
</head>
<body>
<div id="app">嘻嘻 {{baseInfo}} 哈哈</div>
<script type="module">
import Vue from './Vue.js'
const app = new Vue({
el: '#app',
data: {
name: '',
age: 0,
sex: '',
stature: {
weight: '',
height: 0
}
},
watch: {
name(newVla, oldVal) {
console.log('监听到name变化,由' + oldVal + '=>' + newVla)
}
},
computed: {
baseInfo() {
return `我叫${this.name},${this.sex},今年${this.age}岁了。我的身高是${this.stature.weight},体重是${this.stature.weight}`
}
},
created() {
this.name = '王章昊'
this.age = 23
this.sex = '男'
this.stature.weight = '70kg'
this.stature.height = '175cm'
this.formatData()
setTimeout(() => {
this.name = '张艺菡'
console.log(this.baseInfo)
}, 2000)
},
methods: {
formatData() {
console.log(this.baseInfo)
}
}
})
</script>
</body>
</html>