Skip to content

The tree-select component cannot customize the title slot name #4457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task
rennzhang opened this issue Aug 2, 2021 · 1 comment
Closed
1 task

The tree-select component cannot customize the title slot name #4457

rennzhang opened this issue Aug 2, 2021 · 1 comment

Comments

@rennzhang
Copy link

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

Version

2.2.2

Environment

vue 3.1.5

Reproduction link

Edit on CodeSandbox

Steps to reproduce

tree-select 组件无法自定义 title 插槽名称

在使用 treeData 的方式时,我定义node.slots={title:"custom"},并使用插槽:

<template #custom="{ name }">
<span>{{ name }}</span>
<span style="color: rgb(204, 204, 204); margin-left: 10px" class="show-only-dropdown">
资源
</span>
</template>

控制台会出现报错:Uncaught (in promise) TypeError: $slots.title is not a function

What is expected?

能够正常使用插槽

What is actually happening?

控制台会出现报错:Uncaught (in promise) TypeError: $slots.title is not a function


  1. 这里我不确定用法是否正确,但文档没有更加详细的说明,我理解这里应该可以自定义修改插槽名称,如果不能,那么这个属性没有意义,直接slots: true就可以了
  2. 发现的另一个问题,如果我不使用自定义的名称,直接使用文档的用法,即:slots:{title: 'title'},那么前提是这个节点下没有 title 属性才能使用 title 插槽,我认为 title 本身作为默认属性用来展示名称,那么我在使用插槽的时候一定是需要自定义内容的,此时插槽的优先级理应高于默认属性 title

我的业务场景:在某父级组件中处理出来需要使用的 treeData,并向下注入,多处需要使用,但有的地方需要使用插槽自定义内容,有的不需要,上面两个问题导致我不能使用同一数据,必须处理成两份数据,一个是有插槽的,一个是没插槽的

@github-actions github-actions bot changed the title tree-select 组件无法自定义 title 插槽名称 The tree-select component cannot customize the title slot name Aug 2, 2021
@zkwolf zkwolf added 2.x for 2.x bug labels Aug 2, 2021
@github-actions
Copy link

github-actions bot commented Aug 5, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants