I need to attach an onClick=""
event to a Vue component. I am aware that I can use @click=""
, but since this div
is later going to be cloned (I am using a slider library that clones the div
s). I cannot use @click=""
, since the original event handler will not be cloned (apparently this is not possible).
How can I use a vanilla onClick
event handler inside a component, while also referring to the component's method? Usually I'd write:
<a href="#" @click="nextSlide()">
But I cannot use:
<a href="#" onClick="this.nextSlide()">
Since "nextSlide" will then not be defined.