How can I get reference to the element that fired the method in Vue.js? I have HTML like this:
<input type="text" v-model="dataField" v-bind:class="dataFieldClass" />
And in my Vue.js viewmodel I have a method:
dataFieldClass: function () {
// Here I need the element and get its ID
// Pseudo code
var elementId = $element.id;
}
I know that it's possible to get the element from event (v-on:click), but this is not an event, it's a simple method returning CSS class for the element according to few conditions of the viewmodel. It should be computable as well, but the problem is the same.
dataFieldClassmethod will have no idea what element it was used for when binding to a property. Why would want to reference the element? What's the use case?dataFieldobject?dataFieldvariable as a param fordataFieldClass?