vue 路由跳转传参

第一种方式:

<router-link :to="{path:'/my_details/my_comment',query:{userInfo:userInfo.headImage}}" >
  <img src="@/assets/img/my/my_weixin.png" alt />
  <h5>我的评论</h5>
</router-link>

第二种方式:

<div class="my_good_friend_info" @click="chitchat(item.id)">
   <img src="@/assets/img/my/viewhistory2.png" alt />
</div>
 
chitchat(val) {
   this.$router.push({ path: "/my_details/my_chat", query: { id: val } });
},

使用都是一样的:

这样打印,你就知道怎么用了
 
console.log(this.$route.query,'-----------------')
原文地址:https://www.cnblogs.com/tlfe/p/13049882.html