How Vue binds native events to components

Since the event on the component defaults to a custom event, this example 中<child @click="handleClick"></child>will not be recognized by the system as the click event we understand must be bound to it by the $ emit method.

In this way, it is a bit troublesome to define methods inside and outside the component, so what if you want to use native events directly on the component? Add a suffix .native to the event:

Obviously, we recommend the second method, the lack of code is not one line or two lines ~

H-L
Published 8 original articles · Likes5 · Visits 40,000+

Guess you like

Origin blog.csdn.net/helenwei2017/article/details/102553303