current position:Home>Use of Vue on in Vue

Use of Vue on in Vue

2022-04-29 07:10:42Can't find the carved Yang Guo

v-on The parameter problem of

Situation 1 : No parameter

If the method does not require additional parameters , Then the method behind () Can not add

Situation two : There is a parameter

One 、 You can pass in the desired parameters at will
Two 、 Only parentheses are written, but no specific parameter values are written , This is the transmission of undefined
3、 ... and 、 If you don't add parentheses when calling a method , At this time vue The parameters that will help pass are generated by the browser event Event object
Four 、 Active use $event Pass as a parameter event Event object

Situation three : A common parameter is required event Event parameters

Active use $event Just pass it on

v-on Modifier

There are five modifiers

.stop

Stop the event from bubbling

.prevent

Block the trigger of the default time

.{keyCode|keyAlias}

Monitor the click of a key cap

.native

listener component , Later on

.once

An event is only valid when triggered for the first time

A small problem

Element reuse problem Add... To the tag key keyword , If two key If they are different, they will not be reused

v-show

v-if When the condition is false The element does not appear in dom in
v-show When the condition is false It just adds one display:none
High switching frequency v-show, Use when the frequency is very low v-if

copyright notice
author[Can't find the carved Yang Guo],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/116/202204260554326611.html

Random recommended