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中鏈接如果是‘/’開始就是從根路由開始,如果開始不帶‘/’,則從當前路由開始
好歹是人家寫的,那我就給她一個名分,這是原創 https://blog.csdn.net/sangjinchao/article/details/70888259 侵刪