Explanation on the official website:
You may want to listen to a native event on the root element of a component. The v-on modifier .native can be used.
In layman's terms: it is to bind a native event to the custom child component in the parent component, and the event cannot be triggered without adding '. native', as shown in the figure below
<template>
<view>
<TestValue style="color:red" title="hahhaha" @click.native="clickChild" />
</view>
</template>
<script>
import TestValue from '@/components/TestValue.vue'
export default {
components:{
TestValue},
data() {
return {
title: 'Hello'
}
},
onLoad() {
},
methods: {
clickChild(){
uni.showToast({
title:"这是个子组件的事件"})
}
}
}
</script>