Javascript 角度路由器错误-路由配置无效

Javascript 角度路由器错误-路由配置无效,javascript,angular,angular2-routing,url-redirection,Javascript,Angular,Angular2 Routing,Url Redirection,使用angular 4,我使用空路径将路线重定向到导航栏组件。因此,我添加了pathMatch:full,并将此条目放在routes数组的顶部 但我仍然得到以下错误: zone.js:522未处理的承诺拒绝: 路由“”的配置无效。:无法指定数组 区域:根 任务:承诺 值:区域警告错误{ __区域\符号\错误:错误:路由“”的配置无效:数组 无法指定 在Zone.run()[=>角度] 路由组件.ts import {Route} from '@angular/router'; import {

使用angular 4,我使用空路径将路线重定向到导航栏组件。因此,我添加了
pathMatch:full
,并将此条目放在routes数组的顶部

但我仍然得到以下错误:

zone.js:522未处理的承诺拒绝:
路由“”的配置无效。:无法指定数组
区域:根
任务:承诺
值:区域警告错误{
__区域\符号\错误:错误:路由“”的配置无效:数组 无法指定
在Zone.run()[=>角度]

路由组件.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
  }, {
   path: 'registration',
   component: RegistrationComponent
  }
];
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';

import { AppComponent } from './app.component';
import {NavbarComponent} from './navbar/navbar.component';
import {RegistrationComponent} from './registration/registration.component';

import { appRoutes } from './app.route';

@NgModule({
  declarations: [
    AppComponent,
    NavbarComponent,
    RegistrationComponent

  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    RouterModule.forRoot([appRoutes])
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
应用程序模块.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
  }, {
   path: 'registration',
   component: RegistrationComponent
  }
];
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';

import { AppComponent } from './app.component';
import {NavbarComponent} from './navbar/navbar.component';
import {RegistrationComponent} from './registration/registration.component';

import { appRoutes } from './app.route';

@NgModule({
  declarations: [
    AppComponent,
    NavbarComponent,
    RegistrationComponent

  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    RouterModule.forRoot([appRoutes])
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
换衣服

来自

RouterModule.forRoot([appRoutes])

RouterModule.forRoot(appRoutes)

我忘了将appRoutes声明为数组。