doc(transfer): tree-transfer disabled style (#6480)

pull/6489/head
Cherry7 2023-04-21 09:54:05 +08:00 committed by GitHub
parent bf5fcdc269
commit c690f4188a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 8 deletions

View File

@ -78,14 +78,12 @@ function isChecked(selectedKeys: (string | number)[], eventKey: string | number)
return selectedKeys.indexOf(eventKey) !== -1; return selectedKeys.indexOf(eventKey) !== -1;
} }
function handleTreeData(data: TransferProps['dataSource'], targetKeys: string[] = []) { function handleTreeData(treeNodes: TransferProps['dataSource'], targetKeys: string[] = []) {
data.forEach(item => { return treeNodes.map(({ children, ...props }) => ({
item['disabled'] = targetKeys.includes(item.key as any); ...props,
if (item.children) { disabled: targetKeys.includes(props.key as string),
handleTreeData(item.children, targetKeys); children: handleTreeData(children ?? [], targetKeys),
} }));
});
return data as TreeProps['treeData'];
} }
export default defineComponent({ export default defineComponent({