vue页面跳转方法

vue2.0在使用的过程中, .vue文件之间的跳转,需要在router里面配置path,通过路径跳转,html文件跳转如下:

但是有时的需求是页面不直接跳转,有确认弹框或者其他事件,此时就需要在js中设置跳转,方法如下:

  1. this.$ router.push({path: ‘/…’}); path为跳转路径,此方法会产生历史记录
    this.$ router.push({name:’…’}) name也可以作为路由跳转
    this.$ router.push({path:‘home’,query:{obj:’…’}}) query:参数,可通过this.$ route.query.obj获取
    this.$ router.push({path:‘home’,params:{obj:’…’}}) query:参数,可通过this.$route.params.obj获取
  2. this.$router.replace() 此方法不会产生历史记录
  3. this.$router.go(n) 向前或向后跳转n个页面

你可能感兴趣的:(vue页面跳转方法)