Skip to content

Bug: generate-menus.ts 中 resultChildren 出现 Cannot read properties of null (reading 'length') #6116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 tasks done
hiss-github opened this issue May 6, 2025 · 1 comment

Comments

@hiss-github
Copy link

Version

Vben Admin V5

Describe the bug?

具体问题是对 route 进行解构时 children 属性设定的默认值只会在 undefined 时生效,而 null 属于一个有效值。当
hideChildrenInMenu 为 false,resultChildren.length 就会出现如 issue 标题那样的错误。
解决方案:
// 处理子菜单
const resultChildren = hideChildrenInMenu
? []
: (children as MenuRecordRaw[]) ?? [];

Reproduction

具体问题是对 route 进行解构时 children 属性设定的默认值只会在 undefined 时生效,而 null 属于一个有效值。当
hideChildrenInMenu 为 false,resultChildren.length 就会出现如 issue 标题那样的错误。
解决方案:
// 处理子菜单
const resultChildren = hideChildrenInMenu
? []
: (children as MenuRecordRaw[]) ?? [];

System Info

最新版本

Relevant log output

Validations

@anncwb
Copy link
Collaborator

anncwb commented May 6, 2025

fixed #6117

@anncwb anncwb closed this as completed May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants