【发布时间】:2019-12-12 14:09:06
【问题描述】:
使用 Angular 和 md 引导时出现以下错误。
ERROR 错误:未捕获(在承诺中):错误:无法匹配任何路由。 URL 段:“关于”
错误:无法匹配任何路由。 URL 段:“关于” 在输入代码时
HTML
<li class="nav-item">
<a class="nav-link waves-light" routerLink='/About' mdbWavesEffect>About US</a>
</li>
模块测试
import { AppRoutingModule } from './app-routing.module';
const appRoutes: Routes = [
{ path: 'home', component: HomeComponent , pathMatch: 'prefix'},
{ path: 'about', component: AboutComponent , pathMatch: 'prefix'},
{ path: 'contact', component: ContactComponent , pathMatch: 'prefix'}
];
imports: [ RouterModule.forRoot(appRoutes , { enableTracing: true }), ]
【问题讨论】:
-
at app .module.ts:从'./app-routing.module'导入{AppRoutingModule}; const appRoutes: Routes = [ { path: 'home', component: HomeComponent , pathMatch: 'prefix'}, { path: 'about', component: AboutComponent , pathMatch: 'prefix'}, { path: 'contact', component : ContactComponent , pathMatch: 'prefix'} ];导入:[ RouterModule.forRoot(appRoutes , { enableTracing: true }), ]
标签: angular