路由默认404不起作用

时间:2016-08-21 14:57:22

标签: angular angular-universal

当我访问www.myweb.com/something时,网络会显示以下消息:

http://jpg.party/SOME_IMAGE_URL

这是我的app.routes:

{
  "status": 404,
  "message": "No Content"
}

我使用角度通用,所以我有另一个名为server.ts的文件,这个代码:

export const routes: RouterConfig = [
  { path: '', redirectTo: 'account', pathMatch: 'full' },
  { path: 'account', component: Account },
  { path: 'followers', component: Followers },
  { path: 'explore/:id', component: Explore },
  { path: '**', redirectTo: 'account' },
  ];

问题出在哪里?谢谢!

1 个答案:

答案 0 :(得分:1)

你可以在下面试试,

 // notice the slash in front of account navigation
 { path: '**', redirectTo: '/account' } 

如果路径不匹配,它会导航绝对。

希望这会有所帮助!!

相关问题