-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv-计算属性.html
36 lines (35 loc) · 987 Bytes
/
v-计算属性.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>computed计算属性</title>
<script src="js/vue.js"></script>
<script>
window.onload = function () {
new Vue({
el: "#box",
data: {
message: "hello"
},
computed: {//计算属性
reversedMessage: function () {
return this.message.toString().toUpperCase()
}
},
methods: {//方法
reversedMessage2: function () {
return this.message.toUpperCase()
}
}
})
}
</script>
</head>
<body>
<div id="box">
<p>原始字符串: {{ message }}</p>
<p>计算后输出大写字符串: {{ reversedMessage }}</p>
<p>使用方法后输出大写字符串: {{ reversedMessage2() }}</p>
</div>
</body>
</html>