In this article we will introduce to you event processing in vuejs.
Vuejs provides us with a directive calledv:on
, which can help us register and listen fordom
events, so that whenever the event is triggered, The method passed to the event will be called.
v:on
Syntax of the directive
In the above code, we listen for ## on the button #clickevent so that whenever the user clicks on the button, it calls the
handleClickmethod.
{{num}}
How to pass parameters to event handlers?
Sometimes event handler methods can also accept parameters.{{num}}
incrementmethod with only one parameter value to pass the parameters to the
increment(10)method.
How to access the default event object?
To access the default event object in the method vuejs, you need to provide a variable named $event.Shorthand syntax
vuejs also provides a shorthand syntax to listen todomevents.
The above is the detailed content of Vue.JS event handling tutorial and code examples. For more information, please follow other related articles on the PHP Chinese website!