2024-06-12 10:53 / 技术分享 判断 Vue 3.x 子组件被引用时是否被父组件定义事件 要判断的话不能用`defineEmits()`定义事件,不然 `useAttrs()`获取不到事件。废话不多说,直接上代码。 ### Child.vue ``` 重置 查询 ``` ### Parent.vue ``` ``` ### 参考资料 - https://cn.vuejs.org/guide/components/attrs.html - https://cn.vuejs.org/guide/components/events.html#defining-custom-events
发表评论 取消回复