Skip to content

Commit

Permalink
Merge pull request #47 from Godlike-meteor/develop
Browse files Browse the repository at this point in the history
fix(tree-select): data empty bug
  • Loading branch information
xiaosansiji committed Dec 23, 2021
2 parents fe3919e + 6110e74 commit 7a61140
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/tree-select/tree-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,22 @@ export default mixins(getConfigReceiverMixins<Vue, TreeSelectConfig>('treeSelect

if (tree && !this.multiple && this.value) {
const nodeValue = this.isObjectValue ? (this.value as NodeOptions).value : this.value;
const node = (tree as any).getItem(nodeValue);
this.nodeInfo = { label: node.data[this.realLabel], value: node.data[this.realValue] };
// 数据源非空
if (!isEmpty(this.data)) {
const node = (tree as any).getItem(nodeValue);
this.nodeInfo = { label: node.data[this.realLabel], value: node.data[this.realValue] };
} else {
this.nodeInfo = { label: nodeValue, value: nodeValue };
}
} else if (tree && this.multiple && isArray(this.value)) {
this.nodeInfo = this.value.map((value) => {
const nodeValue = this.isObjectValue ? (value as NodeOptions).value : value;
const node = (tree as any).getItem(nodeValue);
return { label: node.data[this.realLabel], value: node.data[this.realValue] };
// 数据源非空
if (!isEmpty(this.data)) {
const node = (tree as any).getItem(nodeValue);
return { label: node.data[this.realLabel], value: node.data[this.realValue] };
}
return { label: nodeValue, value: nodeValue };
});
} else {
this.nodeInfo = null;
Expand Down

0 comments on commit 7a61140

Please sign in to comment.