应用路由.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from '../buyer/home/home.component';
const routes: Routes = [
{path: '', redirectTo:'buyer', pathMatch:"full"}
]
@NgModule({
declarations:[],
imports:[
BrowserModule,
RouterModule.forRoot(routes)
],
exports:[RouterModule]
})
export class AppRoutingModule {}
买家路由.ts
import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core';
import { Routes,RouterModule } from '@angular/router';
import { WelcomeComponent } from './welcome/welcome.component';
import { HomeComponent } from './home/home.component';
@NgModule({
declarations:[],
imports:[
CommonModule,
RouterModule.forChild([
{ path: 'buyer', component: HomeComponent},
{ path: '', redirectTo: '/welcome', pathMatch: 'prefix'},
{ path: 'welcome', component: WelcomeComponent}
])
],
exports:[RouterModule]
})
export class BuyerRoutingModule {}
当我为应用程序服务时。构建已成功创建,但是当我运行应用程序时出现错误。我还通过删除空路径进行了检查,仍然会出现此错误。
main.ts:12 Error: Invalid configuration of route '': routes must have either
a path or a matcher specified