-
Notifications
You must be signed in to change notification settings - Fork 475
/
Copy path07.Inside Computed Properties.html
59 lines (54 loc) · 1.26 KB
/
07.Inside Computed Properties.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<link rel="stylesheet" href="">
<script src="vue.js"></script>
<style>
pre {
margin: 0;
padding: 0.3em;
border: 1px dashed #2f6fab;
background-color: #f9f9f9;
color: black;
line-height: 1em;
font-family: verdana, helvetica, sans-serif;
}
body {
margin-top: 100px;
}
</style>
</head>
<body>
<div id="example">
<h1>打开控制台,vm.example, vm.example1 </h1>
<input type="text" v-model="msg">
msg:{{msg}}
<hr>
每次访问时,时间戳,缓存: {{example}}
<hr>
每次访问时,时间戳,不缓存: {{example1}}
</div>
<script>
var vm = new Vue({
el: '#example',
data: {
msg: 'hi'
},
computed: {
'example': function() {
return Date.now() +"-"+this.msg
},
'example1': {
cache: false, // 关闭缓存
get: function() {
return Date.now() + "-" +this.msg
}
}
}
})
</script>
</body>
</html>