此處介紹三種方式
方式一:
問號后面帶的參數,
例如:/product?id=1&name=iphone還可以是: [routerLink]="['/books']" [queryParams]="{bookname:'《活着》'}
獲取參數的方式:ActivatedRoute.queryParams[id]
方式二:
冒號形式,
例如:path:/product/:id
獲取參數的方式:ActivatedRoute.params[id]
方式三:
js里的路徑跳轉
例如:path:/product,component:ProductComponent,data:[{madeInChina:true}]}
獲取參數的方式: ActivatedRoute.snapshot.data[0][madeInChina]