该错误在使用命名出口时通常会出现。将命名出口添加到路由配置文件中后,必须在导航时指定该出口。以下是示例代码:
在路由配置文件中添加命名出口:
const routes: Routes = [ { path: 'example', component: ExampleComponent, outlet: 'sidebar' },
// other routes ];
在导航时指定命名出口:
this.router.navigate([{ outlets: { sidebar: ['example'] } }]);
这样应该就能解决该错误。