Pass parameter to vue.js @click event handler

October 20, 2020

In your application sometimes you will need to pass parameter to event handler, for example if you want to delete a row from a table, you have to pass the argument  to event handler.

<td><a href="javascript:void(0)" @click="delete_row(attach.id)"> <i class="far fa-trash-alt"></i> </a> </td>

In above code, I am passing the argument attachment id to the event handler delete_row @click

So your event handler will be like this

methods: {
   delete_row: function (id) {
     console.log(id)
   }
}

Normally in delete and update operations in Vue you can use this methods