1. 程式人生 > >vue,router-link傳參以及引數的使用

vue,router-link傳參以及引數的使用

1.路徑:http://localhost:8081/#/test?name=1

<router-link :to="{path:'/test',query: {name: id}}">跳轉</router-link>(id是引數)

使用:this.$route.query.id

2.路徑:http://localhost:8081/#/test/1

<router-link :to="'/test/'+id">跳轉</router-link>(id是引數)

路由:

使用:this.$route.params.id(這個id給上圖路由的配置有關)

this.$route是一個數組,裡面包含路由的所有資訊

注意:router-link中連結如果是‘/’開始就是從根路由開始,如果開始不帶‘/’,則從當前路由開始 ---------------------  作者:sangjinchao  來源:CSDN  原文:https://blog.csdn.net/sangjinchao/article/details/70888259?utm_source=copy  版權宣告:本文為博主原創文章,轉載請附上博文連結!