vue on click v:on

v-on on the <button> tag to listen to the ‘click’ event

example:

 <div id="app">
  <img src="img_moose.jpg">
  <p>{{ "Moose count: " + count }}</p>
  <button v-on:click="count++">Count moose</button>
</div>

<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script>
  const app = Vue.createApp({
    data() {
      return {
        count: 0
      }
    }
  })
 app.mount('#app')
</script> 

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *