<!DOCTYPE html>
<html>
<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>
</head>
<body>
<div id='app'>
{{b}}
</div>
<script src='./vue.js'></script>
<script>
var vm = new Vue({
el: '#app',
data: {
a: 10
},
computed: {
// 计算属性的名字b:值(带return的函数)
// b: function() {
// return this.a + 1;
// }
// 特点:
// 如果b依赖a,此时,当a变化时 b会变化
b() {
return this.a + 1;
}
},
methods: {
}
});
</script>
</body>
</html>
网友评论