vue3 迁移 listeners
# 概览 $listeners 对象在 Vue 3 中已被移除。现在事件监听器是 $attrs 的一部分: { text: ‘this is an attribute’, onClose: () => console.log(‘close Event triggered’) } # 2.x 语法 在 Vue 2 中,你可以使用 this.$attrs 和 this.$listeners 分别访问传递给组件的 attribute 和事件监听器。结合 inheritAttrs: false,开发者可以将这些 attribute 和监听器应用到其它元素,而不是根元素: <template …