How to Stop Event Propagation in Vue.js?

To stop event propagation in Vue.js, you can use the .stop event modifier. Consider for example, an anchor tag where you wish to stop event propagation on click. You could do that in the following way:

<a @click.stop="doSomething">Foo</a>

By introducing event modifiers, Vue.js intends to promote the idea of event handling logic to be purely about data rather than having to deal with DOM event details in there.

Please note that it is also possible to chain different event modifiers together. For example, @click.stop.prevent would stopPropagation and preventDefault.

Hope you found this post useful. It was published . Please show your love and support by sharing this post.