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

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/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.