VueCompilerError: Extraneous children found when component already has explicitly named default slot

使用插槽报错

<el-table-column prop="operation_area" label="操作区" align="center" width="180" />

        <template #default="scope">

        </template>

解决方案:

使用插槽时要注意el-table-column使用双标签

<el-table-column prop="operation_area" label="操作区" align="center" width="180" >

        <template #default="scope">

        </template>

<el-table-column/>

The warning message "Extraneous children found when component already has explicitly named default slot. These children will be ignored." is usually encountered in Vue.js when you try to pass children to a component that already has an explicitly named default slot. In Vue.js, a component can have multiple slots to render different content. By default, any content that is not explicitly assigned to a named slot is rendered in the default slot. However, if a component already has a named default slot, any additional children passed to the component will be ignored and produce this warning. To resolve this issue, you have a few options: 1. If you intended to pass the children to the default slot, make sure that the component does not have any explicitly named default slot. Remove any `slot` attribute with a specific name from the component's template. 2. If you want to assign the children to a named slot, make sure to update the component's usage accordingly. Pass the children as a separate prop or wrap them in a container element and assign that container to the named slot. Here's an example to illustrate the second option: ```vue <template> <div> <slot name="header"></slot> <slot></slot> </div> </template> <script> export default { name: 'MyComponent', } </script> ``` In your parent component: ```vue <template> <my-component> <template v-slot:header> <!-- header content goes here --> </template> <!-- other content goes here --> </my-component> </template> <script> import MyComponent from '@/components/MyComponent.vue' export default { components: { MyComponent, }, } </script> ``` By assigning the children to the named slot, you can avoid the warning message and ensure that the content is rendered correctly within the component.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值