手动导航或刷新浏览器时,角路由无法进行更多细分

时间:2019-04-04 14:39:46

标签: angular routing

我有一个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

1 个答案:

答案 0 :(得分:0)

尝试:

{ path: '', redirectTo: 'post'}
{ path: 'post', component: PostComponent, children: [
    { path:'details',component: DetailsComponent}
  ]
},
{ path: '**', redirectTo: ''}