Vue - handling user inputs with v-on directive

0 votes
256 views
added Oct 25, 2019 in Vue by LC Marshal Captain (25,790 points)
<div id="landrover-5">
  <p>{{ defender }}</p>
  <button v-on:click="reverseDefender">Reverse Defender Text</button>
</div>

<script>
var landrover5 = new Vue({
  el: '#landrover-5',
  data: {
    message: 'Hello Defender'
  },
  methods: {
    reverseDefender: function () {
      this.defender = this.defender.split('').reverse().join('')
    }
  }
})
</script>

<!--output:-->
<!--rednefeD olleH-->

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...