button click event vue js code example

Example 1: click in vue

<button  @click="setComponent('manage')">manage</button>

Example 2: click vue

<button v-on:click="warn('Form cannot be submitted yet.', $event)">
  Submit
</button>



// ...
methods: {
  warn: function (message, event) {
    // now we have access to the native event
    if (event) {
      event.preventDefault()
    }
    alert(message)
  }
}

Example 3: vue js button click

<div id="example-2">
  <!-- `greet` is the name of a method defined below -->
  <button v-on:click="greet">Greet</button>
</div>