Vue event modifier. Passive The most popular understanding

1 Overview

There is a very special modifier in the event modifiers in vue. The official vue document introduces this: .passive tells the browser that you do not want to prevent the default behavior of the event.
If you don’t prevent the default behavior, ordinary thinking is hard to understand. If you don’t prevent it, can’t I just preventDefault? Obviously, this is not the case, otherwise Vue will not produce such an event modifier.

2 Understand.passive

In vue, the default event is not blocked. The real purpose is to tell the browser that you don't need to check whether the program has blocked the default event, that is, tell the browser in advance that the program will not block, so what is the point?
Let me give you a very simple example. You have a friend who is coming to your house. If he tells you in advance, then you can prepare lunch and clean up in advance, but if you don’t tell, you will only know when he comes in. , At that time you will be too late. This is the reason why .passive tells the browser in advance, telling it early to improve performance .

I hope it can help everyone. If you have any questions, you can just comment directly. If you like it, you can like it so that more people can see it. If you are not detailed enough, you can also say it, and I will reply in time.

Guess you like

Origin blog.csdn.net/qq_41800366/article/details/105708918