angular5 路由传参的几种方式?

此处介绍三种方式

方式一:

     问号后面带的参数,

        例如:/product?['/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]