1. router-link跳转

   // 直接写上跳转的地址
<router-link to="/detail/one">
<span class="spanfour" >link跳转</span>
</router-link>
// 添加参数
<router-link :to="{path:'/detail/two', query:{id:1,name:'vue'}}">
</router-link>
// 参数获取
id = this.$route.query.id
// 新窗口打开
<router-link :to="{path:'/detail/three', query:{id:1,name:'vue'}}" target="_blank">
</router-link>

  2. this.$router.push跳转

toDeail (e) {
this.$router.push({path: "/detail", query: {id: e}})
}
// 参数获取
id = this.$route.query.id toDeail (e) {
this.$router.push({name: "/detail", params: {id: e}})
}
// 注意地址需写在 name后面
//参数获取,params和query区别,query参数在地址栏显示,params的参数不在地址栏显示
id = this.$route.params.id

   3. this.$router.replace跳转

//和push的区别,push有记录一个history,replace没有
toDeail (e) {
this.$router.replace({name: '/detail', params: {id: e}})
}

  

  4. resolve跳转

//resolve页面跳转可用新页面打开
//2.1.0版本后,使用路由对象的resolve方法解析路由,可以得到location、router、href等目标路由的信息。得到href就可以使用window.open开新窗口了(这边应用:https://segmentfault.com/q/1010000009557100下的一个回答)
toDeail (e) {
const new = this.$router.resolve({name: '/detail', params: {id: e}})
window.open(new.href,'_blank')
}

接收方怎么接收参数 this.$route.query.serid和this.$route.params.setid,以下举一个接收的例子

注意接收参数时是 $route 不是 $router

<template>
<div>
testDemo{{this.$route.query.setid}}
</div>
</template>

接收的参数:

<template>
<div>userlist--{{mallCode}} </div>
</template> <script>
export default {
name: "UserList",
date:function(){
return {"mallCode":mallCode}
},
created(){
this.getParams()
},
methods:{
getParams() {
// 取到路由带过来的参数
const routerParams = this.$route.query.mallCode;
this.mallCode = routerParams;
console.log(this.$route.query); // 将数据放在当前组件的数据内
//this.mallInfo.searchMap.mallCode = routerParams;
//this.keyupMallName()
}
}
}
</script> <style scoped> </style>

转 :  https://blog.csdn.net/qq_28353055/article/details/84099004

https://blog.csdn.net/Janus_lian/article/details/84965459

vue的跳转方式(打开新页面)及传参的更多相关文章

  1. $router和$route的区别,路由跳转方式name 、 path 和传参方式params 、query的区别

    一.$router和$route的区别 $router : 是路由操作对象,只写对象$route : 路由信息对象,只读对象 例子://$router操作 路由跳转 this.$router.push ...

  2. vue做的项目每次打开新页面不会显示页面顶部的解决办法

    在main.js 中添加代码: router.afterEach((to,from, next) => { window.scrollTo(0,0) }) 然后就会发现每次打开页面都是显示的是页 ...

  3. vue的跳转方式(打开新页面)

    vue的跳转方式(打开新页面) 2018年11月22日 10:43:21 浊清... 阅读数 2043   版权声明:本文为博主原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接和 ...

  4. 点击iframe窗口里的超链接,打开新页面的方式

    点击iframe窗口里的超链接打开新页面的方式: a标签中设置按钮点击事件,事件调用的方法使用如下方法跳转链接:  window.open('url链接', '_blank');

  5. DTcms手机版使用余额支付 提示信息跳转到PC版的错误。以及提交订单不打开新页面

    手机版使用余额支付 提示信息跳转到PC版的错误 引起错误的原因是中间需要提交到DTcms.Web\api\payment\balance\index.aspx去处理 导致BasePage.cs中的li ...

  6. Web设计中打开新页面或页面跳转的方法 js跳转页面

    Web设计中打开新页面或页面跳转的方法 一.asp.net c# 打开新页面或页面跳转 1. 最常用的页面跳转(原窗口被替代):Response.Redirect("newpage.aspx ...

  7. Web设计中打开新页面或页面跳转的方法

    一.asp.net c# 打开新页面或页面跳转 1. 最常用的页面跳转(原窗口被替代):Response.Redirect("newpage.aspx"); 2. 利用url地址打 ...

  8. HBuilder mui 手机app开发 Android手机app开发 ios手机app开发 打开新页面 预加载页面 关闭页面

    创建子页面 在mobile app开发过程中,经常遇到卡头卡尾的页面,此时若使用局部滚动,在android手机上会出现滚动不流畅的问题: mui的解决思路是:将需要滚动的区域通过单独的webview实 ...

  9. iOS如何用代码控制以不同屏幕方向打开新页面?

    转载:http://blogread.cn/it/article/7765?f=wb#original 代码示例:https://github.com/johnlui/Swift-On-iOS/tre ...

  10. angularjs 中state.go 跳转并且打开新的浏览器窗口

    包子最近遇到业务人员提的非常无厘头的需求,就是调页面的时候,一定要打开一个新的浏览器窗口...>o<奇葩!!! 但是我的页面都是state.go跳转的呀,我各种百度,发现,貌似state, ...

随机推荐

  1. 模块化规范:AMD规范和CommonJs规范

    为什么模块很重要? 因为有了模块,我们就可以更方便地使用别人的代码,想要什么功能,就加载什么模块. 但是,这样做有一个前提,那就是大家必须以同样的方式编写模块,否则你有你的写法,我有我的写法,岂不是乱 ...

  2. Android 使用traceView

    Android在做性能优化的时候需要使用traceView进行检测,traceView可以详细的记录下线程执行的时间让我们在做优化的时候可以清楚优化哪些内容.首先我们需要使用这个traceView,在 ...

  3. Centos 7 中的ulimit -n 65535 对进程的文件句柄限制不生效??

    今日闲来无事,就看群里大佬吹牛逼了,偶然一条技术疑问提出来了,神奇啊,作为广大老司机技术交流群体竟然还有这么深入的研究? 大佬问:这个文件句柄限制怎么设置了/etc/security/limits.c ...

  4. Sql 语句中 IN 和 EXISTS 的区别

    IN 语句:只执行一次 确定给定的值是否与子查询或列表中的值相匹配.in在查询的时候,首先查询子查询的表,然后将内表和外表做一个笛卡尔积,然后按照条件进行筛选.所以相对内表比较小的时候,in的速度较快 ...

  5. yaml文件配置logger

    yaml 今天用yaml文件写了一下logging的配置,文件如下: version: 1 disable_existing_loggers: False formatters: simple: fo ...

  6. 【异常】Zipkin server java.lang.IllegalArgumentException: Prometheus requires that all meters with the same name have the same set of tag keys. There is already an existing meter containing tag keys [meth

    解决办法: 添加下面配置就OK #zipkin启动报错无法访问的解决方法 management.metrics.web.server.auto-time-requests: false

  7. 【转】大众点评CAT开源监控系统剖析

    https://www.cnblogs.com/yeahwell/p/cat.html 参考文档: 大众点评的实时监控系统分析(一) CAT_source_analyze 透过CAT,来看分布式实时监 ...

  8. python老师博客

    前端基础之HTML http://www.cnblogs.com/yuanchenqi/articles/6835654.html 前端基础之CSS http://www.cnblogs.com/yu ...

  9. 什么是 MFA?

    Multi-Factor Authentication (MFA) 是一种简单有效的最佳安全实践方法,它能够在用户名和密码之外再额外增加一层安全保护. 启用 MFA 后,用户登录阿里云网站时,系统将要 ...

  10. A A=new A();

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cons ...