[Vuejs]-How to obtain the id (or any other attribute) of the component clicked in Vue template?

2👍

You can access the element clicked from the current event.

The code would look something like this

<a v-on:click="myFunction($event, 'param')">Click me</a>

// in your component
methods: {
    myFunction: function(event, param) {
        console.log(event.target);
    }
}

Leave a comment