1.router-link to 跳转

<router-link to="/child"><button>跳转</button></router-link>

2.this.$router.push("ComponentName") ,通过路由名称跳转

<button @click="go()">跳转</button>
 go(){
this.$router.push("Child");
},

3.this.$router.push({path:"/child"}) ,通过路由的path跳转

<button @click="go2()">跳转</button>
 go2(){
this.$router.push({path:"/child"});
},

4.带参数跳转 this.$router.push({path:"/child",params:{test:123}})

<button @click="go3()">带参数跳转</button>
 go3(){
this.$router.push({path:"/child?test=123"})
},

这种跳转的路由地址和参数是这样的,用问号拼接的,

获取路由参数,this.$route.query.paramsName

<button @click="getParams()">获取路由参数</button>
 getParams(){
console.log(this.$route.query.test); //
}

5.跳转到上一个路由,this.$router.go(-1)

<button @click="goback()">返回上一页</button>
 goback(){
this.$router.go(-1);
}

6.命名路由的跳转,需要在配置路由上带上参数,<router-link :to={name:'ComponentName',params:{test:123}}></router-link>

  {
name:"Children",
path:"/children/:test",
component:Children
}
<router-link :to="{name:'Children',params:{test:123}}"><button>跳转带参数</button></router-link>

这种跳转的路由地址和参数是这样的,用 / 拼接的,

获取路由参数:this.$route.params.xxx

<button @click="getParams()">获取路由参数</button>
 getParams(){
console.log( this.$route.params.test);
}

vue路由跳转的多种方式的更多相关文章

  1. 详解vue 路由跳转四种方式 (带参数)

    详解vue 路由跳转四种方式 (带参数):https://www.jb51.net/article/160401.htm 1.  router-link ? 1 2 3 4 5 6 7 8 9 10 ...

  2. vue 路由跳转带参 方式query ,params

    a.vue向b.vue传值 a.vue this.$router.push({ path: '/payType', query: { putUpList: this.putUpList, name:' ...

  3. vue路由跳转的方式

    vue路由跳转有四种方式 1. router-link 2. this.$router.push() (函数里面调用) 3. this.$router.replace() (用法同push) 4. t ...

  4. Vue通信、传值的多种方式,详解

    Vue通信.传值的多种方式,详解 转自:https://blog.csdn.net/qq_35430000/article/details/79291287 一.通过路由带参数进行传值 ①两个组件 A ...

  5. vue路由跳转报错解决

    vue路由跳转: setTimeout(function () { console.log(this); this.$router.push("/login"); },800) 语 ...

  6. 去除vue路由跳转地址栏后的哈希值#

    去除vue路由跳转地址栏后的哈希值#,我们只需要在路由跳转的管理文件router目录下的index.js中加上一句代码即可去掉哈希值# mode:"history" import ...

  7. Vue路由跳转到新页面时 默认在页面最底部 而不是最顶部 的解决

    今天碰到一个问题   vue路由跳转到新的页面时会直接显示页面最底部  正常情况下是显示的最顶部的  而且好多路由中不是全部都是这种情况  折腾好长时间也没解决  最后在网上找到了解决办法 其实原理很 ...

  8. vue路由跳转取消上个页面的请求和去掉重复请求

    vue路由跳转取消上个页面的请求和去掉重复请求 axios 的二次封装(拦截重复请求.异常统一处理) axios里面拦截重复请求

  9. Vue通信、传值的多种方式,详解(都是干货)

    Vue通信.传值的多种方式,详解(都是干货) 可参考博客: https://blog.csdn.net/qq_35430000/article/details/79291287

随机推荐

  1. HDU 3691 Nubulsa Expo(全局最小割)

    Problem DescriptionYou may not hear about Nubulsa, an island country on the Pacific Ocean. Nubulsa i ...

  2. iOS指令集

    公司在进行项目重构时,其中一个地方的改动就是调整了iOS的指令集.更改指令集主要可以对手机应用的安装机型做出控制,同时在研发过程中也可以控制相关的模拟器和真机.它们原则上是向下兼容的,比如iphone ...

  3. c++实现循环队列

    #include <iostream> #include<stdio.h> #include<stdlib.h> using namespace std; ;// ...

  4. will not be exported or published. Runtime ClassNotFoundExceptions may result.

    在eclipse中加入某个jar包时,会出现Classpath entry XXX.jar will not be exported or published. Runtime ClassNotFou ...

  5. tp框架版本的thinksnsnv4开启调试模式

    首先说下开启调试模式完整操作. 1.\config\config.inc.php配置文件中增加两个键值对 'APP_DEBUG' => true, 'SHOW_PAGE_TRACE' => ...

  6. Linux操作系统-系统安装与分区

    .磁盘分区 使用分区工具在磁盘上划分几个逻辑部分,一旦分成几个分区,不同类型的目录和文件可以存储进不同的分区2.分区类型主分区:最多只能有4个扩展分区:最多只能有1个:主分区加扩展分区最多有4个:扩展 ...

  7. Github上Markdown基本语法

    基础写作和语法格式 本篇文章的内容来源于Github的基础写作帮助.如果在观看时有什么问题,可以直接查阅源文件.另外需要说明的是Git对Markdown的支持增加了一些扩展功能,因此在Git上可以渲染 ...

  8. andorid 对话框

    activity_ui2.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout x ...

  9. Ant.OutputIsUnreadableCode

    Ant在Mac OS X终端中的输出乱码的问题 1. 问题: 在用Ant脚本进行构建Android App时,在编译失败时,Ant 输出有乱码. 2. 环境: Mac OS X, 简体中文版.在Ter ...

  10. (O)编写可维护的代码示例(原创)

    图片轮播: /*广告图片数组*/ var imgs=[ {"i":0,"img":"images/index/banner_01.jpg"} ...