savoie
0
Q:

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>
0

<button @click="btnClick()"> </button>

//inside the script section, define the function:

export default{
 .
  data(){
   return{
    click:false
    };
  },
  methods:{
   btnClick(){
     this.click=!this.click;   //toggles click between true/false
      }
  }
};
0
<button @click="doSumthin">
  Do Something
</button>
<script>
module.exports {
  methods: {
    doSumthin() {
      console.log('did something!');
    }
  },
};
</script>
-2

New to Communities?

Join the community