一:router-link標簽跳轉
<router-link to='/citylist'><div class="header-right">城市</div></router-link>
<router-link :to="{path:'/partysubject',query:{id:3}}"></router-link>
二:
<button @click = "func()">跳轉</button> <script> export default{ methods:{ func (){ this.$router.push({name: '/order/page1',params:{ id:'1'}}); } } } </script>
補充一下第二點:
this.$router.push({path: ''/order/index''}); this.$router.push({path: '/order/page1',query:{ id:'2'}}); this.$router.push({name: '/order/page2',params:{ id:'6'}});
query要用path來引入,params要用name來引入,接收參數都是類似的,分別是this.$route.query.name和this.$route.params.name。
query更加類似於我們ajax中get傳參,params則類似於post,說的再簡單一點,前者在瀏覽器地址欄中顯示參數,后者則不顯示