From e42062847533fa977ebe0c4b6e71a3462899c060 Mon Sep 17 00:00:00 2001 From: aixianling Date: Fri, 7 Apr 2023 08:36:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E7=BB=84=E8=BD=AC=E6=A0=91=E7=BB=93?= =?UTF-8?q?=E6=9E=84,=E5=88=A0=E9=99=A4=E7=A9=BA=E7=9A=84=E5=AD=90?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E6=95=B0=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/lib/js/utils.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ui/lib/js/utils.js b/ui/lib/js/utils.js index 800cb061..dde5ccdf 100644 --- a/ui/lib/js/utils.js +++ b/ui/lib/js/utils.js @@ -54,6 +54,12 @@ const $arr2tree = (list, config = {}) => { itemMap[pid].children.push(treeItem) } else result.push(treeItem) } + const removeNullChildren = node => { + if (node[children] && node[children].length > 0) { + node[children].map(c => removeNullChildren(c)) + } else delete node[children] + } + result.forEach(removeNullChildren) return result }