温馨提示×

vue如何路由跳转

vue
养鱼的猫咪
195
2021-05-10 08:37:01
栏目: 编程语言
Vue开发者专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

在vue中实现路由跳转的方法有:1.使用this.$router.push()跳转;2.使用router-link跳转;vue如何路由跳转

在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}}">

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:vue中路由跳转的方式有哪些

0