how to fix 'Error: Cannot match any routes. URL Segment: 'anythongs''
how to fix 'Error: Cannot match any routes. URL Segment: 'anythongs''
我的 angular 项目中的路线系统有问题。我每次调用 reset-password/:token
路由时都会收到此错误。
每次我调用此路由 http://localhost:4200/reset-password?token=token_info
时,浏览器 (google chrome) 将我重定向到 http://localhost:4200/reset-password
和 return 此错误消息。
core.js:1673 ERROR 错误:未捕获(承诺):错误:无法匹配任何路由。 URL 段:'reset-password'
错误:无法匹配任何路由。 URL 段:'reset-password'
在 ApplyRedirects.push../node_modules/@angular/router/fesm5/router.js.ApplyRedirects.noMatchError (router.js:1384)
在 CatchSubscriber.selector (router.js:1365)
在 CatchSubscriber.push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchSubscriber.error (catchError.js:34)
在 MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:80)
在 MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:60)
在 MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:80)
在 MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:60)
在 MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:80)
在 MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:60)
在 TapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/tap.js.TapSubscriber._error (tap.js:61)
在 resolvePromise (zone.js:814)
在 resolvePromise (zone.js:771)
在 zone.js:873
在 ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
在 Object.onInvokeTask (core.js:3811)
在 ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
在 Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
在 drainMicroTaskQueue (zone.js:595)
另一方面,所有其他道路都在运行
这是我的代码
app.module.ts
const appRoutes: Routes = [{
path: '',
component: LoginLayoutComponent,
children: [
{ path: '', component: SigninComponent },
{
path: 'forgot-password',
component: ForgotPasswordComponent,
},
{
path: 'forgot-password/confirmation',
component: ForgotPasswordConfirmationComponent,
},
{
path: 'reset-password/:token',
component: ResetPasswordComponent,
},
{ path: 'signup', component: SignupComponent },
{ path: 'logout', component: LogoutComponent, canActivate: [
CanActivateViaAuthGuard
]
},
]
},
你能帮帮我吗?谢谢。
在 { path: 'reset-password/:token', ... }
对象之前添加 reset-password
作为路由。
您的 'reset-password' 路由需要一个令牌参数,
可能是你打电话给路线的时候错过了。
您已使用令牌定义 'reset-password/:token',因此您需要使用该路由传递令牌。
您要么必须通过该路由传递令牌,要么定义另一条没有令牌的路由。
我的 angular 项目中的路线系统有问题。我每次调用 reset-password/:token
路由时都会收到此错误。
每次我调用此路由 http://localhost:4200/reset-password?token=token_info
时,浏览器 (google chrome) 将我重定向到 http://localhost:4200/reset-password
和 return 此错误消息。
core.js:1673 ERROR 错误:未捕获(承诺):错误:无法匹配任何路由。 URL 段:'reset-password' 错误:无法匹配任何路由。 URL 段:'reset-password' 在 ApplyRedirects.push../node_modules/@angular/router/fesm5/router.js.ApplyRedirects.noMatchError (router.js:1384) 在 CatchSubscriber.selector (router.js:1365) 在 CatchSubscriber.push../node_modules/rxjs/_esm5/internal/operators/catchError.js.CatchSubscriber.error (catchError.js:34) 在 MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:80) 在 MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:60) 在 MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:80) 在 MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:60) 在 MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber._error (Subscriber.js:80) 在 MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.error (Subscriber.js:60) 在 TapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/tap.js.TapSubscriber._error (tap.js:61) 在 resolvePromise (zone.js:814) 在 resolvePromise (zone.js:771) 在 zone.js:873 在 ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421) 在 Object.onInvokeTask (core.js:3811) 在 ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420) 在 Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188) 在 drainMicroTaskQueue (zone.js:595)
另一方面,所有其他道路都在运行
这是我的代码
app.module.ts
const appRoutes: Routes = [{
path: '',
component: LoginLayoutComponent,
children: [
{ path: '', component: SigninComponent },
{
path: 'forgot-password',
component: ForgotPasswordComponent,
},
{
path: 'forgot-password/confirmation',
component: ForgotPasswordConfirmationComponent,
},
{
path: 'reset-password/:token',
component: ResetPasswordComponent,
},
{ path: 'signup', component: SignupComponent },
{ path: 'logout', component: LogoutComponent, canActivate: [
CanActivateViaAuthGuard
]
},
]
},
你能帮帮我吗?谢谢。
在 { path: 'reset-password/:token', ... }
对象之前添加 reset-password
作为路由。
您的 'reset-password' 路由需要一个令牌参数, 可能是你打电话给路线的时候错过了。
您已使用令牌定义 'reset-password/:token',因此您需要使用该路由传递令牌。
您要么必须通过该路由传递令牌,要么定义另一条没有令牌的路由。