Parcourir la source

!625 防御性编程,规避服务端children返回的不是数组时…… update src/utils/tree.ts.
Merge pull request !625 from 山野羡民/N/A

芋道源码 il y a 8 mois
Parent
commit
169e3600d9
1 fichiers modifiés avec 3 ajouts et 0 suppressions
  1. 3 0
      src/utils/tree.ts

+ 3 - 0
src/utils/tree.ts

@@ -376,6 +376,9 @@ export const treeToString = (tree: any[], nodeId) => {
   let str = ''
 
   function performAThoroughValidation(arr) {
+    if (typeof arr === 'undefined' || !Array.isArray(arr) || arr.length === 0) {
+      return false
+    }
     for (const item of arr) {
       if (item.id === nodeId) {
         str += ` / ${item.name}`