vue的路由带参数和取参数

1、写在html里

<router-link :to="{path:'/goldShop/goodsInfo',query: { id:item.id }}" class="swiperBG">

2、写在js里

this.$router.push({
   path: '/goldShop/allGoods'
 })
 this.$router.push({
    path:`/goldShop/payInfo`,
    query:{id:this.id,num:this.num}//带参
  })
console.log(this.$route.query.id);//取值

猜你喜欢

转载自www.cnblogs.com/chenluqing/p/11428894.html