【发布时间】:2020-02-04 13:12:58
【问题描述】:
我是 Angular 8 的新手。 任何帮助或提示将不胜感激!! 这是我的 app.routing.module.ts:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LabViewerComponent } from './lab-viewer/lab-viewer.component';
import { HomeComponent } from './home/home.component';
const routes: Routes = [
{ path: '', component: HomeComponent},
{ path: 'home', component: HomeComponent},
{ path: 'LabViewerPDF', component: LabViewerComponent}
];
@NgModule({
imports: [RouterModule.forRoot(routes, {useHash: true})],
exports: [RouterModule]
})
export class AppRoutingModule { }
这是我的 home.component.html:
Home
<a (click)="selectLab()">Click here to download my Plan (PDF)</a>
<router-outlet></router-outlet>
这是我的 app.component.html:
app component
<a (click)="selectLab()">Click here to download my Plan (PDF)</a>
<router-outlet></router-outlet>
不知道为什么这个网址: http://localhost:4200/#/home
显示: 应用组件 点击这里下载我的计划 (PDF)首页 点击这里下载我的计划 (PDF)
应该是: home component 点击这里下载我的计划 (PDF)Home 点击这里下载我的计划 (PDF)
【问题讨论】:
-
由于 {useHash: true},您的 URL 中有一个 #,您能指定 pb 吗?
标签: angular