console
new Vue({
el: "#app",
data: {
name: 'abyss',
counter: 0,
secondCounter: 0
},
computed: {
output: function() {
console.log('Computed');
return this.counter > 5 ? "Greater 5" : "Smaller 5";
}
},
watch: {
counter: function(value) {
var vm = this;
setTimeout(function() {
vm.secondCounter++;
}, 2000)
}
},
methods: {
result: function() {
console.log('method');
return this.counter > 5 ? "Greater 5" : "Smaller 5";
}
}
});
<div id="app">
<button v-on:click="counter++">Increase</button>
<button v-on:click="counter--">Decrease</button>
<button v-on:click="secondCounter++">Increase Second</button>
<p>Counter: {{ counter }} | {{ secondCounter }}</p>
<p>Result: {{ result() }} | {{ output }}</p>
</div>