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中鏈接如果是‘/'開始就是從根路由開始,如果開始不帶‘/',則從當前路由開始
以上這篇vue router-link傳參以及參數的使用實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林網。
新聞熱點
疑難解答