在vue中實現路由跳轉的方法有:1.使用this.$router.push()跳轉;2.使用router-link跳轉;
在vue中實現路由跳轉的方法有以下幾種
1.使用this.$router.push()跳轉
1)不帶參跳轉
this.$router.push('/home')
this.$router.push({name:'home'})
this.$router.push({path:'/home'})
2)帶參跳轉
this.$router.push({name:'home',query: {id:'1'}})
this.$router.push({path:'/home',query: {id:'1'}})
this.$router.push({name:'home',params: {id:'1'}})
2.使用router-link跳轉
1)不帶參跳轉
<router-link :to="{name:'home'}"><router-link :to="{path:'/home'}">
2)帶參跳轉
<router-link :to="{name:'home', params: {id:1}}">
<router-link :to="{name:'home', query: {id:1}}">