feat: 当children为空数组是认为是叶子节点 (#143)

* feat: 当children为空数组是认为是叶子节点
This commit is contained in:
GaoNeng 2023-04-18 20:03:44 +08:00 committed by GitHub
parent 7613d098c5
commit 01294ad47b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -17,6 +17,11 @@ export default {
value: 'zhinan',
label: '指南',
children: [
{
value: 'quick-started',
label: '快速开始',
children: []
},
{
value: 'anzhuang',
label: '安装',

View File

@ -45,7 +45,7 @@ export default class Node {
const childrenKey = config.children
const childrenData = this.data[childrenKey]
this.hasChildren = Array.isArray(childrenData)
this.hasChildren = Array.isArray(childrenData) && childrenData.length > 0
this.children = (childrenData || []).map((child) => new Node(child, config, this))
}