这种类型的路径不起作用:
{ path: 'account/finalize?user=:user&token=:token', component: MyComponent }
当我访问http://localhost:4200/account/cinallize?user = devanshu& token = 122323
时,我会发现未找到路由的错误。,但这在起作用:
{ path: 'account/finalize/:school/:token', component: MyComponent }
所以,我可以访问http://localhost:4200/account/finalize/devanshu/122323
这里有什么问题?为什么在第一种情况下出现错误?
您可以使用
path: 'account/finalize'
导航时将用户和令牌作为查询参数发送
this.router.navigate(['/account/finalize'], { queryParams: { user: 'user', token: 'your token' } });
我认为您不需要传递以下参数: user=:user&token=:token
您可以在req.body
,如果有任何特定的组件,则必须将条件放置在功能中。