我有一个Angular路由问题,特别是路由问题。手动导航或浏览器刷新时,路由使多个网段失败
{path:'post',component: PostComponent}
{path:'post/details',component: DetailsComponent}
当浏览器刷新或手动导航第一个路径时,但带有/ details的路径失败并显示错误,如下所示
post:41 GET http://localhost:4200/post/runtime.js
post:41 GET http://localhost:4200/post/polyfills.js
post:41 GET http://localhost:4200/post/styles.js
post:41 GET http://localhost:4200/post/vendor.js
post:41 GET http://localhost:4200/post/main.js
答案 0 :(得分:0)
尝试:
{ path: '', redirectTo: 'post'}
{ path: 'post', component: PostComponent, children: [
{ path:'details',component: DetailsComponent}
]
},
{ path: '**', redirectTo: ''}