Linux 拨号vps windows公众号手机端

vue如何路由跳转

lewis 6年前 (2019-04-09) 阅读数 10 #程序编程
文章标签 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)带参跳转

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

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门