vue路由跳轉有四種方式
1. router-link
2. this.$router.push() (函數里面調用)
3. this.$router.replace() (用法同push)
4. this.$router.go(n)
一、不帶參
1.1 router-link
1.2 this.$router.push()
二、帶參
2.1 router-link
2.2 this.$router.push(query傳參
this.$router.go(n)
this.$router.go(n) this.$router.go(n) 向前或者向后跳轉n個頁面,n可為正整數或負整數
區別:
this.$router.push 跳轉到指定url路徑,並想history棧中添加一個記錄,點擊后退會返回到上一個頁面
this.$router.replace 跳轉到指定url路徑,但是history棧中不會有記錄,點擊返回會跳轉到上上個頁面 (就是直接替換了當前頁面)
this.$router.go(n) 向前或者向后跳轉n個頁面,n可為正整數或負整數
__EOF__
來 源:麋鹿魯喲