關於this.$router.push、replace、go的用法和區別


this.$router.push
跳轉到指定url路徑,並想history棧中添加一個記錄,點擊后退會返回到上一個頁面

// 字符串

this.$router.push('index')

// 對象

this.$router.push({path: 'login-pw'})

// 帶參數

this.$router.push({path: 'login-pw', query: {'account': this.account.account}})

// 跳轉后的頁面獲取參數

this.account.account = this.$route.query.account

 

this.$router.replace

跳轉到指定url路徑,但是history棧中不會有記錄,點擊返回會跳轉到上上個頁面

this.$router.go(n)

向前或者向后跳轉n個頁面,n可為正整數或負整數


免責聲明!

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



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