1.路由跳轉(zhuǎn)a標(biāo)簽
<a routerLink="['three/ccd3', 'abc',{?c:?'123'?}]">ccd3</a>
routerLink 第一項(xiàng)為路由袍镀, 第二項(xiàng)必選參數(shù)(若無可以省略),第三項(xiàng)為可選參數(shù) 用{} 包起來冻晤;
2.routing.module.ts的配置 /:a 苇羡,表示必選參數(shù)a
const?routes:?Routes?=?[
????{?path:?'ccd3/:a',?component:?Ccd3Component?},
];
3.接收參數(shù)
constructor( private?route:?ActivatedRoute)?{}
ngOnInit()?{
????????this.route.paramMap.subscribe(params?=>?{
????????????console.log(params);
????????????this.name?=?params['a'];
????????});
?}