最近开发一套微信音乐小程序框架使用vue3,但还是要吐槽一下,有时候会突然报错,怎么也调试不好,过段时间自己又好了,这让开发者体验极差。下面说下遇到的一些问题
Extraneous non-emits event listeners (close) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only
如果使用vue2 子组件的暴露给父组件的写法会报这个警告。需要在vue3的写法,在emits中提前声明。
javascript
//vue2
this.$emit('close')
//修改
export default {
name: 'popup',
emits: ['close'],
methods: {
close() {
this.$emit('close')
},
}
}