The order of event modifiers in vue

order is important when using modifiers; the corresponding code is generated in the same order. Therefore, using v-on:click.prevent.self blocks all clicks, while v-on:click.self.prevent only blocks clicks on the element itself.

did not quite understand this sentence in the official document, and then looked for it on the Internet and did not find a detailed analysis of this sentence. V-on:click.prevent is the default behavior that blocks all passed events, followed by the addition that the callback function is triggered only when the element itself is triggered, is that what you mean?

Mar.05,2021

it means that the latter will not be executed until the previous conditions are met.

// a
<div class="a">
    <div class="b"></div>
</div>

a.@click.self.prevent="c"apreventcbaapreventc

a.@click.prevent.self="c"preventpreventacc

so this sentence on the official website, v-on:click.prevent.self will block all clicks, meaning that it will block the default events of all clicks, and only clicking on the current element will trigger the events you define. By the same token, you can understand the latter sentence.


Menu