我正在构建一个角度应用程序,一切正常,直到导入并实现了“路由模块”
错误信息
我已经经历了,不认为以下是可能的问题:
路由器模块代码:
import { NgModule } from '@angular/core';
import { Routes , RouterModule } from '@angular/router';
import { RecipesComponent } from './recipes/recipes.component';
import { ShoppingListComponent } from './shopping-list/shopping-list.component';
const appRoutes: Routes = [
{path: 'recipes', component: RecipesComponent},
{path: 'shopping-list', component: ShoppingListComponent},
{ path: '', redirectTo: 'recipes', pathMatch: 'full'},
{ path: '**', redirectTo: '/not-found'},
]
@NgModule({
imports: [
RouterModule.forRoot(appRoutes),
],
exports: [AppRoutingModule]
})
export class AppRoutingModule{
}Run Code Online (Sandbox Code Playgroud)
根组件代码:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule …Run Code Online (Sandbox Code Playgroud)