From 40d08f73bb118a5c0c5992ae269270e8d9d705b6 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Mon, 25 Oct 2021 16:40:08 +0800 Subject: [PATCH] fix: tree fieldNames for key error, close #4790 --- components/tree/index.en-US.md | 2 +- components/tree/index.zh-CN.md | 2 +- components/vc-tree/Tree.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/tree/index.en-US.md b/components/tree/index.en-US.md index 221fc376f..e3be9b5f4 100644 --- a/components/tree/index.en-US.md +++ b/components/tree/index.en-US.md @@ -18,7 +18,7 @@ Almost anything can be represented in a tree structure. Examples include directo | Property | Description | Type | Default | Version | | --- | --- | --- | --- | --- | | treeData | treeNode of tree, please use `treeNodes` before v1.1.4 | [TreeNode[]](#TreeNode) | - | | -| replaceFields | Replace the title,key and children fields in treeNode with the corresponding fields in treeData | object | { children:'children', title:'title', key:'key' } | | +| fieldNames | Replace the title,key and children fields in treeNode with the corresponding fields in treeData | object | { children:'children', title:'title', key:'key' } | 3.0.0 | | autoExpandParent | Whether to automatically expand a parent treeNode | boolean | true | | | blockNode | Whether treeNode fill remaining horizontal space | boolean | false | | | checkable | Adds a `Checkbox` before the treeNodes | boolean | false | | diff --git a/components/tree/index.zh-CN.md b/components/tree/index.zh-CN.md index 733ec6d8b..58c7f9ac5 100644 --- a/components/tree/index.zh-CN.md +++ b/components/tree/index.zh-CN.md @@ -20,7 +20,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/Xh-oWqg9k/Tree.svg | --- | --- | --- | --- | --- | --- | | blockNode | 是否节点占据一行 | boolean | false | | | treeData | treeNodes 数据,如果设置则不需要手动构造 TreeNode 节点(key 在整个树范围内唯一) | [TreeNode[]](#TreeNode) | -- | | -| replaceFields | 替换 treeNode 中 title,key,children 字段为 treeData 中对应的字段 | object | {children:'children', title:'title', key:'key' } | | +| fieldNames | 替换 treeNode 中 title,key,children 字段为 treeData 中对应的字段 | object | {children:'children', title:'title', key:'key' } | 3.0.0 | | autoExpandParent | 是否自动展开父节点 | boolean | true | | | checkable | 节点前添加 Checkbox 复选框 | boolean | false | | | checkedKeys(v-model) | (受控)选中复选框的树节点(注意:父子节点有关联,如果传入父节点 key,则子节点自动选中;相应当子节点 key 都传入,父节点也自动选中。当设置`checkable`和`checkStrictly`,它是一个有`checked`和`halfChecked`属性的对象,并且父子节点的选中与否不再关联 | string\[] \| number\[] \| {checked: string\[] \| number\[], halfChecked: string\[] \| number\[]} | \[] | | diff --git a/components/vc-tree/Tree.tsx b/components/vc-tree/Tree.tsx index b246dea7c..476801ba6 100644 --- a/components/vc-tree/Tree.tsx +++ b/components/vc-tree/Tree.tsx @@ -595,7 +595,7 @@ export default defineComponent({ const onNodeCheck = (e: MouseEvent, treeNode: EventDataNode, checked: boolean) => { const { checkStrictly, onCheck } = props; - const { key } = treeNode; + const key = treeNode[fieldNames.value.key]; // Prepare trigger arguments let checkedObj;