Event handler V-ON
We said before that v-on is an instruction that can take parameters, but this is a bit awkward for many students. In fact, we said that it is easier to understand by adding V-on in front of some special attributes. For example, click.
Examples of writing:
<button v-on:click=" button "> </button>Copy the code
So today we’re going to relearn what v-On really does, which is an event handler.
What do you mean? That is, there are events that can be associated with this element to trigger the associated events for certain actions. These events are usually expressions, functions, etc., and inside functions you can do anything.
Take this example:
Change the value of the data variable counter in the vue constructor to increment by 1 by binding an expression. The change will then be displayed in real time within the P tag.
Consider the following example:
Here we’re binding a function name
In the following example, the function takes parameters
In the figure, the function needs a parameter called message. When we bind, we need to pass the parameter into the function name and parentheses. Eventually the message pops up with an Alert. Notice that within the specific function, the code is still traditional JS, or JQ. So we still want to master a certain JS/JQ foundation can.
Ok, that’s it for this lesson, how about that, doesn’t it feel easy?? Feel simple, immediately pay attention to this public number ~ into the group learning please add V: Qingwanjianhua
This article uses the article synchronization assistant to synchronize