Suppose I have this template in vue:
<p @click="handleParagraphClick">
<span @click="handleSpanClick">Some text</span>
</p>
When I click on span I trigger also a paragraph click handler running. There is such checking for jquery to check if bubbling triggered a click:
$('#id_of_p').click(function(event) {
if (event.target == this) {
// event was triggered on the body
}
});
When I use event.target
within handleParagraphClick(event)
I get reference to span element. How to get reference to paragraph to compare span event.target
and paragraph this
variable like in jquery?
Upd.
Template above is simplified version of my current code. I have nested components. Component with span is rendered inside paragraph component.
`, you can use `@click.self="handleParagraphClick"`
– Phil Mar 11 '20 at 22:39