(十一)利用指令控制路由

2018-02-18  本文已影响0人  我拥抱着我的未来

本节知识点

this.$router.go(-1) 和this.$router.go(1)

<button @click="add"></button>
<script>
export default {
  name:"app",
data(){
  return {
     message:"Hello"
   }
},
methods:{
   add:function(){
    this.$router.go(-1)
               }
}
}
</script>

备注this.$router.go(-1)就是后退到上一个 this.$router.go(1)就是前进

this.$router.push('/xxx') 跳转到指定的页面

<button @click="gowhere"></button>
<script>
export default {
  name:"app",
data(){
  return {
     message:"Hello"
   }
},
methods:{
   gowhere:function(){
    this.$router.push("/xxx")
               }
}
}
</script>
上一篇 下一篇

猜你喜欢

热点阅读