I din't get any docs for native
event modifiers. I have seen some where like this:
<router-link @click.native="pressThis()"> Press here </router-link>
what is the use of native
modifier on router-link
click event
.
and what other use case native
modifier can have ?
Vue provides event modifiers for v-on by calling directive postfixes denoted by a dot. .stop. .prevent. .capture. .self.
$v is an object that calls vuelidate (at the time of writing the comment, supported in version Vue. js 2.0), which is intended to check every input, which is made in a non-html form.
Vue (pronounced /vjuː/, like view) is a JavaScript framework for building user interfaces. It builds on top of standard HTML, CSS and JavaScript, and provides a declarative and component-based programming model that helps you efficiently develop user interfaces, be it simple or complex.
once Event Modifier. It allows the event to execute only once. Syntax: <button v-on:click.
You can override Vue events in custom components. For instance, you might have a list component that once you click an item you call this.$emit('click', selectedItemData)
, and that will emit the click event to the parent component that is watching that.
However, sometimes you really want to bind to the native HTML/DOM event listener element.addEventListener('click', callThisMethod)
, and that's the use of .native
. Also, make a note that it will handle cleaning the event listener once your component gets destroyed just like a non-native event.
In sum: use .native
when you need the 'raw' event from DOM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With