Using the @click directive in Vue

In this article, you will learn how to use the @click directive to handle events in vue. It is worthy of note, that the @click…

The post Using the @click directive in Vue appeared first on CodeSource.io.


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

In this article, you will learn how to use the @click directive to handle events in vue.

It is worthy of note, that the @click directive is similar to v-on:click event handler.

lets assume we have a method that logs a simple message to the console.

  methods: {
    displayMessage() {
      console.log("Throws a sample message");
    },
  },

We can trigger this function by using the @click directive to call the function.

<template>
  <div>
    <button type="button" @click="displayMessage">Call Message</button>
  </div>
</template>

The post Using the @click directive in Vue 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-03-04T07:51:41+00:00) Using the @click directive in Vue. Retrieved from https://www.scien.cx/2021/03/04/using-the-click-directive-in-vue/

MLA
" » Using the @click directive in Vue." Prince Chukwudire | Sciencx - Thursday March 4, 2021, https://www.scien.cx/2021/03/04/using-the-click-directive-in-vue/
HARVARD
Prince Chukwudire | Sciencx Thursday March 4, 2021 » Using the @click directive in Vue., viewed ,<https://www.scien.cx/2021/03/04/using-the-click-directive-in-vue/>
VANCOUVER
Prince Chukwudire | Sciencx - » Using the @click directive in Vue. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/03/04/using-the-click-directive-in-vue/
CHICAGO
" » Using the @click directive in Vue." Prince Chukwudire | Sciencx - Accessed . https://www.scien.cx/2021/03/04/using-the-click-directive-in-vue/
IEEE
" » Using the @click directive in Vue." Prince Chukwudire | Sciencx [Online]. Available: https://www.scien.cx/2021/03/04/using-the-click-directive-in-vue/. [Accessed: ]
rf:citation
» Using the @click directive in Vue | Prince Chukwudire | Sciencx | https://www.scien.cx/2021/03/04/using-the-click-directive-in-vue/ |

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.