一、router-link標簽跳轉 (聲明式)
<router-link to='xxx.html'><button>點我到新頁面</button></router-link>
二、綁定點擊事件跳轉 (編程式)
1、先綁定newPage()方法
<button @click="newPage">回到首頁</button>
2、在script模塊里加入newPage方法,並用this.$router.push(‘/’)導航到新頁面
export default {
name: 'app',
methods: {
newPage(){
this.$router.push('/dashboard');//或者 this.$router.push({ path:'/new.html'})
}
}
}
三、其他
// 后退一步記錄,等同於 history.back() this.$router.go(-1)