使用 angular 4,我将带有空路径的路由重定向到导航栏组件。所以我添加了pathMatch: full这个条目并将其放在路由数组的顶部。
但我仍然收到以下错误:
zone.js:522 未处理的承诺拒绝:
路由配置无效:无法指定数组;
区域:根;
任务: Promise.then ;
值:ZoneAwareError {
__zone_symbol__error: Error: Invalid configuration of route '': Array cannot be specified
at Zone.run ( http://localhost:4200/polyfills.bundle.js:6405:43 ) [ => angular]
路由.component.ts
import {Route} from '@angular/router';
import { AppComponent } from './app.component';
import {NavbarComponent} from './navbar/navbar.component';
import {RegistrationComponent} from './registration/registration.component';
export const appRoutes:Route =[
{
path: '',
redirectTo: 'navbar',
pathMatch: 'full'
}, {
path: 'home',
component: NavbarComponent
}, {
path: 'navbar',
component: NavbarComponent …Run Code Online (Sandbox Code Playgroud)