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中鏈接如果是‘/’開始就是從根路由開始,如果開始不帶‘/’,則從當前路由開始


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM