Skip to content

Commit 32f669b

Browse files
authored
fix: treeNode customTitle cannot get selected prop
* Tree组件中,treeNode配置scopedSlots: {title: 'customeTitle' },无法获取title插槽的slot-scope值 需要定制tree的title时,具体的值在treeNode的数据上,但现在无法获取title处的插槽参数。经过查看ant-design-vue源码,发现TreeNode.jsx文件在title处配置错误,希望能尽快修复 * Update TreeNode.jsx
1 parent 1112f2f commit 32f669b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

components/vc-tree/src/TreeNode.jsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ const TreeNode = {
420420
vcTree: { prefixCls, showIcon, icon: treeIcon, draggable, loadData },
421421
} = this;
422422
const disabled = this.isDisabled();
423-
const title = getComponentFromProp(this, 'title') || defaultTitle;
423+
const title = getComponentFromProp(this, 'title', {}, false);
424424
const wrapClass = `${prefixCls}-node-content-wrapper`;
425425

426426
// Icon - Still show loading icon when loading without showIcon
@@ -439,9 +439,15 @@ const TreeNode = {
439439
$icon = this.renderIcon();
440440
}
441441

442-
// Title
443-
const $title = <span class={`${prefixCls}-title`}>{title}</span>;
444-
442+
const currentTitle = title;
443+
let $title = currentTitle ? (
444+
<span class={`${prefixCls}-title`}>
445+
{typeof currentTitle === 'function' ? currentTitle({ ...this.$props }, h) : currentTitle}
446+
</span>
447+
) : (
448+
<span class={`${prefixCls}-title`}>{defaultTitle}</span>
449+
);
450+
445451
return (
446452
<span
447453
key="selector"

0 commit comments

Comments
 (0)