Handling Click Events with Vue onclick

In this guide, we will look at event handling using Vue onclick directive. Say we have an element (supposedly a button) that we want to…

The post Handling Click Events with Vue onclick appeared first on CodeSource.io.


This content originally appeared on CodeSource.io and was authored by Prince Chukwudire

In this guide, we will look at event handling using Vue onclick directive. Say we have an element (supposedly a button) that we want to trigger a function on click, this directive comes in handy.

<template>
  <div>
    <button type="button" v-on:click="doSomething">Display</button>
  </div>
</template>

<script>
export default {
  methods: {
    doSomething() {
      alert("Done said something");
    },
  },
};
</script>

The onclick directive can also be referenced as such:

 <button type="button" @click="doSomething">Display</button>

The post Handling Click Events with Vue onclick appeared first on CodeSource.io.


This content originally appeared on CodeSource.io and was authored by Prince Chukwudire


Print Share Comment Cite Upload Translate Updates
APA

Prince Chukwudire | Sciencx (2021-02-18T16:46:46+00:00) Handling Click Events with Vue onclick. Retrieved from https://www.scien.cx/2021/02/18/handling-click-events-with-vue-onclick/

MLA
" » Handling Click Events with Vue onclick." Prince Chukwudire | Sciencx - Thursday February 18, 2021, https://www.scien.cx/2021/02/18/handling-click-events-with-vue-onclick/
HARVARD
Prince Chukwudire | Sciencx Thursday February 18, 2021 » Handling Click Events with Vue onclick., viewed ,<https://www.scien.cx/2021/02/18/handling-click-events-with-vue-onclick/>
VANCOUVER
Prince Chukwudire | Sciencx - » Handling Click Events with Vue onclick. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/02/18/handling-click-events-with-vue-onclick/
CHICAGO
" » Handling Click Events with Vue onclick." Prince Chukwudire | Sciencx - Accessed . https://www.scien.cx/2021/02/18/handling-click-events-with-vue-onclick/
IEEE
" » Handling Click Events with Vue onclick." Prince Chukwudire | Sciencx [Online]. Available: https://www.scien.cx/2021/02/18/handling-click-events-with-vue-onclick/. [Accessed: ]
rf:citation
» Handling Click Events with Vue onclick | Prince Chukwudire | Sciencx | https://www.scien.cx/2021/02/18/handling-click-events-with-vue-onclick/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.