您可能需要适当的加载程序来处理此文件类型。 Angular 5 app中的错误

时间:2018-04-04 05:17:54

标签: angular angular-routing

我刚开始学习角度5.现在我得到了以下错误

  

编译失败。

./src/app/route/app.routing.ts
Module parse failed: Unexpected token (4:28)
You may need an appropriate loader to handle this file type.
| Object.defineProperty(exports, "__esModule", { value: true });
| var appRoutes = [
|     { path: '', component:  }
| ];
| 
 @ ./src/app/app.module.ts 11:20-50
 @ ./src/main.ts
 @ multi (webpack)-dev-server/client?http://0.0.0.0:0 ./src/main.ts

和我的app.routing.ts文件

import { RouterModule, Routes } from '@angular/router';

import { ProductListComponent } from '../product-list/product-list.component';

const appRoutes : Routes = [

    {path: '', component: ProductListComponent, pathMatch:'full'},
    {path:'product-list', component: ProductListComponent, pathMatch: 'full'},
    {path: '**', redirectTo: ''}

];

export const routing = RouterModule.forRoot(appRoutes);

我无法找出错误的真正含义。请帮助

1 个答案:

答案 0 :(得分:0)

尝试redirectTo

const appRoutes : Routes = [

    {path: '', redirectTo: '/product-list', pathMatch: 'full'},
    {path:'product-list', component: ProductListComponent, pathMatch: 'full'},
    {path: '**', redirectTo: ''}

];