Categories

Feb 4 in Vue.JS
Q: What are the event modifiers provided by vue in VueJS?

1 Answer

Feb 4
Normally, javascript provides event.preventDefault() or event.stopPropagation() inside event handlers. You can use methods provided by vue, but these methods are meant for data logic instead of dealing with DOM events. Vue provides below event modifiers for v-on and these modifiers are directive postfixes denoted by a dot.

.stop

.prevent

.capture

.self

.once

.passive

Let's take an example of stop modifier,

<!-- the click event's propagation will be stopped -->

<a v-on:click.stop="methodCall"></a>

You can also chain modifiers as below,

<!-- modifiers can be chained -->

<a v-on:click.stop.prevent="doThat"></a>
Click here to read more about Vue JS
Click here to read more about Insurance

Related questions

Madanswer
Oct 21, 2019 in Vue.JS
Feb 4 in Vue.JS
Feb 4 in Vue.JS
...