>与上方同理,但是有区别 >app-routing.module.ts 中使用 路由配置 ~~~ {path:'detail2/:aid',component:Detail2Component}, ~~~ >在接受组件 detail2.component.ts ~~~ import { Component, OnInit } from '@angular/core'; import {ActivatedRoute} from "@angular/router"; @Component({ selector: 'app-detail2', templateUrl: './detail2.component.html', styleUrls: ['./detail2.component.css'] }) export class Detail2Component implements OnInit { constructor(public route:ActivatedRoute) { } public aid:string; ngOnInit(): void { this.route.params.subscribe(res=>{ this.aid=res.aid; }); } } ~~~