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