gpt4 book ai didi

angular 6 child 路线组件未加载?

转载 作者:搜寻专家 更新时间:2023-10-30 22:06:19 26 4
gpt4 key购买 nike

我有一个小问题。

我有应用程序,我在 Angular 6 中执行此操作,我正在使用子路由

像这样

{
path:'pages', component:DatePagesComponent,
children : [
{path:'404', component:Error404Component},
{path:'500', component:Error500Component}
]
}

我的 html 看起来像

<li [routerLinkActive]="['active']"><a [routerLink]="['/pages/404']">404</a></li>
<li [routerLinkActive]="['active']"><a [routerLink]="['/pages/500']">500</a></li>

它可以很好地加载带有 url 的路由,但总是加载到这个 component:DatePagesComponent

如果我点击 404,页面 url 会发生变化,但组件路由器不会发生变化

我在写

<router-outlet></router-outlet>

进入我的app.components.html 文件

能否请您告诉我这是什么问题以及如何解决它。

最佳答案

你还需要写<router-outlet></router-outlet>给你的DatePagesComponenthtml 文件。这将使您的子路由与 DatePagesComponent 相关联。工作。

关于angular 6 child 路线组件未加载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50791033/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com