首页 > 解决方案 > 使用核心 UI Angular 模板为不同用户自定义导航,但我在控制台中遇到一些奇怪的错误

问题描述

AppSidebarNavItemsComponent.html:33 错误类型错误:无法在 Router.push../node_modules/@angular/router/fesm5/router.js.Router.createUrlTree (router.js:1902) 处读取未定义的属性“长度”。 .js:4220) 在 AppSidebarNavLinkComponent.push../node_modules/@coreui/angular/fesm5/coreui-angular.js.AppSidebarNavLinkComponent.ngOnInit (coreui-angular.js:1317) 在 checkAndUpdateDirectiveInline (core.js:22494) 在 checkAndUpdateNodeInline (core.js:31090) 在 checkAndUpdateNode (core.js:31052) 在 debugCheckAndUpdateNode (core.js:31686) 在 debugCheckDirectivesFn (core.js:31646) 在 Object.eval [as updateDirectives] (AppSidebarNavItemsComponent.html:33) 在Object.debugUpdateDirectives [as updateDirectives] (core.js:31638)

标签: angularcore-ui

解决方案


我发现我的问题是导航项的定义不正确。

确保没有 URL 的项目被正确标记为divider: true或者title: true

对我来说有问题的元素是:

{
    name: 'HELLO'
}

将其更改为:

{
    name: 'HELLO',
    title: true
}

不再出现控制台错误,我可以随意更改项目而不会出错。


推荐阅读