【发布时间】:2017-11-20 15:18:56
【问题描述】:
这是我的代码
<html>
<head>
<script src="https://unpkg.com/vue"></script>
<meta charset="utf-8">
</head>
<body>
<div id="app">
<button v-on:click="increase">plus</button>
<p>Counter : {{ counter }}</p>
<p>Clicks : {{ clicks }}</p>
</div>
<script>
var app = new Vue({
el:'#app',
data:{
counter : 0,
clicks : 0
},
methods:{
increase(){
this.clicks++;
}
},
computed:{
counter: function(){
return this.clicks * 2;
}
}
});
</script>
</body>
</html>
当我点击按钮时,计数器应该会显示两倍的点击次数,但它不起作用。
此代码正在运行:COMPUTED PROPERTIES | VueJS 2 | Learning the Basics。
【问题讨论】:
-
当你说它不起作用时,究竟是什么不起作用?它在做什么?
标签: vue.js