声明式导航router-link标签
<router-link to="/">Home</router-link>
编程式导航this.$router.push();
// 字符串
this.$router.push('children')
// 对象
this.$router.push({ path: 'children' })
<template>
<div class="test">
<a-button type="primary" @click="pushChildren">go children</a-button>
<a-button @click="pushHome">go home</a-button>
</div>
</template>
<script>
export default {
name: "test",
components: {
},
methods: {
pushChildren() {
this.$router.push('children')
},
pushHome() {
this.$router.push({path : 'home'}) //注意home正确的路由应该是'/'而不是'home'
}
}
};
</script>