Extraneous non-emits event listeners (xxx) were passed to component but could not be automatically i
Extraneous non-emits event listeners (xxx) 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
Extraneous non-emits event listeners (editItem, delItem) 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 “emits” option.
无关的非emits事件侦听器(editItem、delItem)已传递给组件,但无法自动继承,因为组件呈现片段或文本根节点。如果侦听器仅用于组件自定义事件侦听器,请使用“emits”选项声明它。
最近使用vue3写,我真麻了,疯狂报这个错误,刚开始通过翻译是说
我就以为是我父子组件传值中的emit写法有问题,还特意专门用方法来包裹下,结果是一直报这个错误。百度说是有个根组件才行。。。
<button class="edit_btn" @click="edit(i) ">编辑</button>
<button class="del_btn" @click="$emit('delItem',i)">删除</button>
const edit = (index) => {
emit('editItem', index);
};
于是我在子组件加了个根元素,还是报这个错误。。。
于是我又去给父组件加。。。
错误消失。。。
我不理解,vue3不是有个特点就是不需要写根元素吗,template下能有多个子元素。。。不是很理解
更多推荐
所有评论(0)