diff --git a/antdv-demo b/antdv-demo index 7da5429bd..6213d13ef 160000 --- a/antdv-demo +++ b/antdv-demo @@ -1 +1 @@ -Subproject commit 7da5429bd5556f6a87c065f6675b963e45f7a83b +Subproject commit 6213d13ef5f287b16a05ff5509b444a662570944 diff --git a/components/tree-select/index.jsx b/components/tree-select/index.jsx index d65d6afa2..7d91ffe86 100644 --- a/components/tree-select/index.jsx +++ b/components/tree-select/index.jsx @@ -63,8 +63,21 @@ const TreeSelect = { }, updateTreeData(treeData) { const { $scopedSlots } = this; + const defaultFields = { + children: 'children', + title: 'title', + key: 'key', + label: 'label', + value: 'value', + }; + const replaceFields = { ...defaultFields, ...this.$props.replaceFields }; return treeData.map(item => { - const { label, title, scopedSlots = {}, children } = item; + const { scopedSlots = {} } = item; + const label = item[replaceFields.label]; + const title = item[replaceFields.title]; + const value = item[replaceFields.value]; + const key = item[replaceFields.key]; + const children = item[replaceFields.children]; let newLabel = typeof label === 'function' ? label(this.$createElement) : label; let newTitle = typeof title === 'function' ? title(this.$createElement) : title; if (!newLabel && scopedSlots.label && $scopedSlots[scopedSlots.label]) { @@ -76,7 +89,9 @@ const TreeSelect = { const treeNodeProps = { ...item, title: newTitle || newLabel, + value, dataRef: item, + key, }; if (children) { return { ...treeNodeProps, children: this.updateTreeData(children) }; diff --git a/components/tree-select/interface.jsx b/components/tree-select/interface.jsx index c2765b0a6..f506a721d 100644 --- a/components/tree-select/interface.jsx +++ b/components/tree-select/interface.jsx @@ -53,4 +53,5 @@ export const TreeSelectProps = () => ({ treeDefaultExpandedKeys: PropTypes.array, treeNodeFilterProp: PropTypes.string, treeNodeLabelProp: PropTypes.string, + replaceFields: PropTypes.object.def({}), }); diff --git a/types/tree-select.d.ts b/types/tree-select.d.ts index 6050c67b5..c538c776b 100644 --- a/types/tree-select.d.ts +++ b/types/tree-select.d.ts @@ -222,6 +222,8 @@ export declare class TreeSelect extends AntdComponent { clearIcon?: any; + replaceFields: object; + /** * remove focus */