繁体   English   中英

Angular2-无法重定向到NotFound页面

[英]Angular2 - can't redirectTo NotFound page

如果用户输入错误网址,我想将用户重定向到“找不到页面” 我看到了这篇文章本页,并尝试了自己的项目。 但是当我输入东西时会出错:

Invalid route configuration of route '/**': path cannot start with a slash

我的app.routing.ts

export const routes: Routes = [
    {
        path: 'home',
        component: AppComponent,
        children: [
            {
                path: '',
                component: LoginComponent
            }
        ]
    },
    {
        path: "/**",
        redirectTo: 'home',
        pathMatch: 'full'
    },
]

如果所有路径与路线都不匹配,我想重定向到主页

更改为关注,

{
        path: "**",
        redirectTo: 'home',
        pathMatch: 'full'
},

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM