. Native modifier
The official interpretation of the. Native modifier is:
Sometimes, you might want to listen to a native event on the root element of a component. The modifier v-on that can be used . Native . For example:
<v-on:click.native= "dothething"></my-component >
The simple point of understanding is:
- Listen for an event to an ordinary HTML tag, and then add the . Native modifier will not work. For example:
HTML code
<id= "app"> <href= "#" v-on:click.native= "Clickfun">click me</a> </ Div >
JavaScript code
New Vue ({' #app 'function() {Console.log ("message:success") }})
Results
- Listens for an event on the root element of a component, and then adds the. Native modifier will work. For example:
HTML code
<id= "app"> <v-on:click.native= "Clickfun"></my-component></div>
JavaScript code
Vue.component (' my-component ', {Template: '<a href= ' # ' >click me</a> '})new ' #app 'function() {Console.log ("message:success") }})
Results
vue.js. Native modifier