我是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>不确定为什么此url:http://localhost:4200/#/home
显示:应用程序组件单击此处下载我的计划(PDF)主页单击此处下载我的计划(PDF)
应该是:主页组件单击此处下载我的计划(PDF)主页单击此处下载我的计划(PDF)
发布于 2020-02-04 21:28:34
图中显示了包含根路由器插座的AppComponent:
app component
<a (click)="selectLab()">Click here to download my Plan (PDF)</a>
<router-outlet></router-outlet>当您导航到home时,路由器插座将按顺序装满HomeComponent (其余部分保持不变),因此您将获得:
<a (click)="selectLab()">Click here to download my Plan (PDF)</a>
<!-- main router outlet's contents here: -->
Home
<a (click)="selectLab()">Click here to download my Plan (PDF)</a>
<!-- this router outlet will be filled, if `home` has any child routes -->
<router-outlet></router-outlet>发布于 2020-02-04 21:38:38
<router-outlet></router-outlet>包含当前路由。你想通过点击某处的路由器链接,将主页加载到路由器插座上。我怀疑这就是你想要发生的事情。
Home
<a (click)="selectLab()">Click here to download my Plan (PDF)</a>app component
<router-outlet></router-outlet>https://stackoverflow.com/questions/60058212
复制相似问题