一、this.$router.push
說明:跳轉到指定URL,向history棧添加一個新的記錄,點擊后退會返回至上一個頁面
使用:
this.$router.push('/index') this.$router.push({path:'/index'}) this.$router.push({path:'/index',query:{name: '123'}}) this.$router.push({name:'index',params:{name:'123'}})
二、this.$router.replace
說明:跳轉到指定URL,替換history棧中最后一個記錄,點擊后退會返回至上上一個頁面
使用:同push
三、this.$router.go(n)
說明:類似window.history.go(n),向前或向后跳轉n個頁面,n可正(先后跳轉)可負(向前跳轉)
使用:
this.$router.go(1) //類似history.forward() this.$router.go(-1) //類似history.back()