我在RouteConfig中定义了routeParam:
{ path: '/user/:id',name: 'User',component: User }@H_301_12@userSelected(userid) { this._router.navigate(['User',{ id: userid }]); }@H_301_12@编译器告诉我以下内容:
Argument of type ‘(string | { id: any; })[]’ is not assignable to parameter of type ‘string.
如何键入参数id,以便编译器将其检测为数字?
解决方法
我会直接使用this._router.navigateByUrl(‘user /’userid);