JSFiddle - React, Tailwind, and code Playground

by mbudnik

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() {
      return this.counter > 5 ? 'Greater 5' : 'Smaller 5';
    }
  },
  methods: {
    result() {
      return this.counter > 5 ? 'Greater 5' : 'Smaller 5';
    }
  }


})