Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What is the use of the .native modifier in Vue.js

Shulou Source: shulou.com Published: 2022-05-31 13:18:59 09月27日 Update

This article mainly introduces the relevant knowledge of "what is the use of.native modifier in Vue.js". Xiaobian shows you the operation process through actual cases. The operation method is simple, fast and practical. I hope this article "what is the use of.native modifier in Vue.js" can help you solve the problem.

The official interpretation of the.native modifier is:

Sometimes you might want to listen for a native event on the root element of a component. You can use the v-on modifier.native. For example:

To put it simply:

Listening for an event to a normal HTML tag and then adding the.native modifier doesn't work. For example:

HTML code

click me

JavaScript code

new Vue({ el: '#app', methods: { clickFun: function(){ console.log("message: success") } }})

results

Listen for an event on the root element of a component, and then add the.native modifier. For example:

HTML code

JavaScript code

Vue.component('my-component', { template: `click me`})new Vue({ el: '#app', methods: { clickFun: function(){ console.log("message: success") } }})

results

About "Vue.js in.native modifier what to use" content introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the industry information channel. Xiaobian will update different knowledge points for you every day.

Tags: Code events knowledge monitoring functions elements components results industries different practical ordinary content official practical practical that is articles methods more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Technology Linux Huawei Docker