一、跳转

  1. <a [routerLink]="['/detail']" [queryParams]="{id:id}">跳转detail</a>

二、接受this.route.queryParams

  1. //导入正在显示的路由
  2. import {ActivatedRoute} from '@angular/router'
  3. export class DetailComponent implements OnInit {
  4. //构造函数中配置
  5. constructor(public route:ActivatedRoute) { }
  6. ngOnInit() {
  7. //subscribe触发
  8. this.route.queryParams.subscribe(res=>{
  9. console.log(res)
  10. })
  11. }
  12. }