我刚开始学习角度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
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);
我无法找出错误的真正含义。请帮助
答案 0 :(得分:0)
尝试redirectTo
const appRoutes : Routes = [
{path: '', redirectTo: '/product-list', pathMatch: 'full'},
{path:'product-list', component: ProductListComponent, pathMatch: 'full'},
{path: '**', redirectTo: ''}
];