首页 > 解决方案 > url中的查询参数不适用于角度

问题描述

当我在 URL 中使用查询参数时,出现以下错误:

ERROR 错误:未捕获(在承诺中):错误:无法匹配任何路由。URL 段:'home/instagram/overview%3Fcode%3D7a6e5944cae649248dfad5509d8e6e67' 错误:无法匹配任何路由。URL 段:'home/instagram/overview%3Fcode%3D7a6e5944cae649248dfad5509d8e6e67' 在 ApplyRedirects.push../node_modules/@angular/router/fesm5/router.js.ApplyRedirects.noMatchError (router.js:2469) 在 CatchSubscriber.selector (router .js:2450)

这是我的路由:

import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {InstagramComponent} from './instagram.component';
import {InstagramAnalysisComponent} from './instagram-analysis   /instagram-analysis.component';

const instagramRoutes: Routes = [
  {
path: '', component: InstagramComponent,
children: [
  {path: 'overview', loadChildren: './instagram-overview/io.module#IoModule'},
  {path: 'content-production', loadChildren: './instagram-content/instagram-content-production/icp.module#IcpModule'},
  {path: 'all-content', loadChildren: './instagram-content/instagram-all-content/iac.module#IacModule'},
  {path: 'analyz', component: InstagramAnalysisComponent},
  {path: 'create/addig', loadChildren: './add-instagram/add-ig.module#AddIgModule'},
]
  }
];

@NgModule({
  imports: [
RouterModule.forChild(instagramRoutes)
  ],
  exports: [
    RouterModule
   ]
})
export class InstagramRoutingModule {
}

我希望下面的 URL 可以正常工作,但这不起作用: http://localhost:4200/home/instagram/create/addig?code=7a6e5944cae649248dfad5509d8e6e67

我必须在路由中做些什么来解决这个问题?

标签: angularrouting

解决方案


推荐阅读