JSFiddle - React, Tailwind, and code Playground
by _SyLaR_
HTML
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>
<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>
JavaScript
new Vue({
el: '#app',
data: {
counter: 0,
secondCounter: 0
},
computed: {
output: function() {
console.log('Computed');
return this.counter > 5 ? 'Greater than 5' : 'Lesser than 5';
}
},
methods: {
result: function() {
console.log('Method');
return this.counter > 5 ? 'Greater than 5' : 'Lesser than 5';
}
}
});