1. 声明式导航router-link标签

      1. <router-link to="/">Home</router-link>
    2. 编程式导航this.$router.push();

    1. // 字符串
    2. this.$router.push('children')
    3. // 对象
    4. this.$router.push({ path: 'children' })
    1. <template>
    2. <div class="test">
    3. <a-button type="primary" @click="pushChildren">go children</a-button>
    4. <a-button @click="pushHome">go home</a-button>
    5. </div>
    6. </template>
    7. <script>
    8. export default {
    9. name: "test",
    10. components: {
    11. },
    12. methods: {
    13. pushChildren() {
    14. this.$router.push('children')
    15. },
    16. pushHome() {
    17. this.$router.push({path : 'home'}) //注意home正确的路由应该是'/'而不是'home'
    18. }
    19. }
    20. };
    21. </script>