import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { HomeComponent } from './home/home.component'; import { AboutComponent } from './about/about.component';
const routes: Routes = [ { path: '', component: HomeComponent }, { path: 'about', component: AboutComponent }, ];
@NgModule({ imports: [RouterModule.forRoot(routes)], exports: [RouterModule] }) export class AppRoutingModule { }
通过排除这些问题,您应该能够解决angular12中路由未正确加载的问题。