2022
我们一起努力

vue如何路由跳转

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)带参跳转

vue如何路由跳转

<router-link :to="{name:'home', params: {id:1}}">
<router-link :to="{name:'home', query: {id:1}}">

赞(0)
文章名称:《vue如何路由跳转》
文章链接:https://www.fzvps.com/71513.html
本站文章来源于互联网,如有侵权,请联系管理删除,本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。
图片版权归属各自创作者所有,图片水印出于防止被无耻之徒盗取劳动成果的目的。

评论 抢沙发

评论前必须登录!