angular6 路由拼接查询参数如 ?id=1 并获取url参数

angular6 路由拼接查询参数如 ?id=1 并获取url参数

路由拼接参数:

<div class="category-border" [routerLink]="['/list/' + category.id + '/' + category.slug]" [queryParams]="{id: 1}">

拼接后在浏览器显示: 域名  http://localhost:4200/?id=1

angular 获取参数 id 的值: 
  引用API: import { ActivatedRoute, Params } from ‘@angular/router’;

this.activeRoute.queryParams.subscribe((params: Params) => {
      this.source = params['id'];
    });

 

原文地址:https://www.cnblogs.com/wjw1014/p/11414591.html