vue点击实现 路由的跳转

点击按钮实现路由的跳转

<div @click="gotoMenu">按钮</div>

实现跳转

methods: {
    gotoMenu(){
      //跳转到上一次浏览的页面  this.$router.go(-1)
      this.$router.go(-1)

      //指定跳转的地址 this.$router.replace('/menu')
      this.$router.replace('/menu')

      //指定跳转的路由的名字下 this.$router.replace({name:'menu'})
      this.$router.replace({name:'menu'})

      //通过push进行跳转
      this.$router.push('/menu')
    }
  },
}

猜你喜欢

转载自www.cnblogs.com/chz1905/p/10954227.html