methods vue code example

Example 1: vue methods

<template>
  <div id="example">
    <button v-on:click="greet">Greet</button>
  </div>
</template>

<script>
export default {
  methods: {
    greet: function(event) {
      // `event` is the native DOM event
      alert(event.target.tagName);
    }
  }
};
</script>

Example 2: event vueks

new Vue({
  el: '#example-3',
  methods: {
    say: function (message) {
      alert(message)
    }
  }
})

Example 3: vue methods v-on =!

<div class="nav-right-items menuBtn" @click="test">
methods: {
  test: function() {
    this.mobileClick = !this.mobileClick
  }
},

Tags: