Skip to content

Commit 169e360

Browse files
YunaiVgitee-org
authored andcommitted
!625 防御性编程,规避服务端children返回的不是数组时…… update src/utils/tree.ts.
Merge pull request !625 from 山野羡民/N/A
2 parents e891a4b + b5aa9d2 commit 169e360

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)