1. 程式人生 > >vue路由跳轉 返回上一級 this.$router.go(-1) 和返回到指定頁面this.$router.push('/home')

vue路由跳轉 返回上一級 this.$router.go(-1) 和返回到指定頁面this.$router.push('/home')

name nbsp style span button pre 頁面 -c out

1,點擊返回上一頁
<button @click="goback">goback</button>
methods:{
goback(){}
this.$router.go(-1)
}
2,點擊跳轉到/Foo2頁面
<button @click="ToLink1">goback</button>
ToLink1(){
this.$router.push(‘/foo2‘) 最常用
或者this.$router.push({name:‘Foo1‘})對象的方法
 

vue路由跳轉 返回上一級 this.$router.go(-1) 和返回到指定頁面this.$router.push('/home')