Vue2.x Cli3.x name属性及跳转方法

Menu.vue

<template>
  <div class="menu">
    <h1>This is an menu page</h1>
    <button @click="web_back()" class="btn btn-success">返回上一个页面</button>
  </div>
</template>
<script>
export default {
  methods:{
    web_back:function(){
      //跳转至上一次访问的页面
      // this.$router.go(-1);
      //跳转至指定地址(path)
      //this.$router.replace('/about');
      //跳转到制定路由名字(name)
      // this.$router.replace({name:'about'});

      //通过push进行跳转(path)
      // this.$router.push('/about')
      // 通过push及逆行跳转(name)
      this.$router.push({name:'about'});

    }
  },
}
</script>
Last modification:May 26th, 2019 at 03:05 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment