Skip to content

Commit b5aa9d2

Browse files
liyujiang-gzugitee-org
authored andcommitted
防御性编程,规避服务端children返回的不是数组时…… update src/utils/tree.ts.
Signed-off-by: 山野羡民 <[email protected]>
1 parent e891a4b commit b5aa9d2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/utils/tree.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@ export const treeToString = (tree: any[], nodeId) => {
376376
let str = ''
377377

378378
function performAThoroughValidation(arr) {
379+
if (typeof arr === 'undefined' || !Array.isArray(arr) || arr.length === 0) {
380+
return false
381+
}
379382
for (const item of arr) {
380383
if (item.id === nodeId) {
381384
str += ` / ${item.name}`

0 commit comments

Comments
 (0)