From 32f669bd4854d926f30a2c788142ccfc042ad56b Mon Sep 17 00:00:00 2001 From: cubemoon Date: Fri, 17 Apr 2020 18:27:51 +0800 Subject: [PATCH] fix: treeNode customTitle cannot get selected prop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Tree组件中,treeNode配置scopedSlots: {title: 'customeTitle' },无法获取title插槽的slot-scope值 需要定制tree的title时,具体的值在treeNode的数据上,但现在无法获取title处的插槽参数。经过查看ant-design-vue源码,发现TreeNode.jsx文件在title处配置错误,希望能尽快修复 * Update TreeNode.jsx --- components/vc-tree/src/TreeNode.jsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/components/vc-tree/src/TreeNode.jsx b/components/vc-tree/src/TreeNode.jsx index 112ebd763..7b679a509 100644 --- a/components/vc-tree/src/TreeNode.jsx +++ b/components/vc-tree/src/TreeNode.jsx @@ -420,7 +420,7 @@ const TreeNode = { vcTree: { prefixCls, showIcon, icon: treeIcon, draggable, loadData }, } = this; const disabled = this.isDisabled(); - const title = getComponentFromProp(this, 'title') || defaultTitle; + const title = getComponentFromProp(this, 'title', {}, false); const wrapClass = `${prefixCls}-node-content-wrapper`; // Icon - Still show loading icon when loading without showIcon @@ -439,9 +439,15 @@ const TreeNode = { $icon = this.renderIcon(); } - // Title - const $title = {title}; - + const currentTitle = title; + let $title = currentTitle ? ( + + {typeof currentTitle === 'function' ? currentTitle({ ...this.$props }, h) : currentTitle} + + ) : ( + {defaultTitle} + ); + return (