Skip to content

a-tabs组件的默认slot插槽中无法渲染自定义组件 #6920

@lisenz

Description

@lisenz
  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

4.0.0-rc.6

Environment

vue3.2,ant-design-vue 4.0.0

Steps to reproduce

我对a-tabs组件以及tab-pane组件分别进行了封装,以下是我封装的组件代码:
notification.vue

<template>
  <div class="my-notifications-tabs">
  <a-tabs :animated="false">
  <slot></slot>
  </a-tabs>
  </div>
</template>
<script setup>
defineOptions({
name: 'notification'
});
</script>

notificationTab.vue

<template>
<a-tab-pane :key="key" :tab="title" class="my-notifications-tab">
<div class="my-notifications-container">
<slot name="top"></slot>
<div class="my-notifications-container-list">
<slot></slot>
</div>
</div>
</a-tab-pane>
</template>
<script setup>
const $props = defineProps({
title: {
type: String,
required: true
},
key: {
type: String
});
</script>

在App.vue中使用

<notification>
<notification-tab key="1" title="Tab 1">Content of Tab Pane 1</notification-tab>
<notification-tab key="2" title="Tab 2">Content of Tab Pane 2</notification-tab>
</notification>

但是渲染出来的效果是只有Content of Tab Pane 1这个内容有出现,标签页没有渲染出来,但是如果我把 notification-tab 组件换成 a-tab-pane 组件,就能正常渲染出标签页,请问tabs是否子组件只能是 a-tab-pane

What is expected?

能与在a-tabs组件中使用 a-tab-pane 组件一样

What is actually happening?

无法渲染出二次封装的 a-tab-pane 组件

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions