报错
non-emits event listeners (chaneel) 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, declare it using the "em
原因 :因为传递事件的子组件没有根节点或者有两个节点,他在父组件中渲染为代码片段,
解决方法
方法一
给子组件加上根节点 外层套一个div
方法二
子组件中声明emits
emits: ['chaneel'], //chaneel 自组件发布的事件