How to pass a parameter to Vue @click event handler
To pass a parameter to a Vue @click event handler, follow these steps:
- In the template, use the v-on directive to listen to the click event and call a method, passing the parameter using the method call.
<button v-on:click="handleClick('example')">Click me</button>
- In the methods section of the Vue instance, define the method and accept the parameter.
methods: {
handleClick(parameter) {
// Your code here
}
}