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. JAVA项目从运维部署到项目开发(四. Tomcat)

    一.关于中文乱码问题 文件目录:/conf/server.xml 将相关语句改为: <Connector port="8008" protocol="HTTP/1. ...

  2. nginx 405错误

    nginx配置文件加上location / { try_files $uri $uri/ /index.php?$query_string; }

  3. python中print用法

    print用法 参考文档:https://blog.csdn.net/sinat_28576553/article/details/81154912 目录 一.print()函数概述 二.变量的输出 ...

  4. 【干货】gitlab-11.10.4版本汉化

    目录 1.YUM安装gitlab-11.10.4 2.gitlab汉化技能 1.YUM安装gitlab-11.10.4 下载gitlab-ce的repo [root@localhost ~]# cur ...

  5. prometheus学习系列四: Prometheus详述

    数据模型 Prometheus 是将所有数据存为时序数据. 每个时序数据是由指标名称和可选的键值对(称之为标签)唯一标识. 度量类型 counter: 单调递增的计数器,如果标识已经服务的请求数量可以 ...

  6. python之提升程序性能的解决方案

    Python在性能方面不卓越,但是使用一些小技巧,可以提高Python程序的性能,避免不必要的资源浪费. 1. 使用局部变量 尽可能使用局部变量替代全局变量,可以是程序易于维护并且有助于提高性能节约成 ...

  7. C/C++解题常用STL大礼包 含vector,map,set,queue(含优先队列) ,stack的常用用法

    每次忘记都去查,真难啊 /* C/C++解题常用STL大礼包 含vector,map,set,queue(含优先队列) ,stack的常用用法 */ /* vector常用用法 */ //头文件 #i ...

  8. Java 并发,相关术语

    Java 并发,相关术语: 术语 作用 synchronize 可修饰方法.代码块.类:介绍:https://www.cnblogs.com/zyxiaohuihui/p/9096882.html L ...

  9. wordpress如何防止url被篡改

    一位网友反馈说他的wordpress网站经常被篡改url,访问网站直接跳到不相关的页面,只能进入数据库那修改wp_option表中修改homeurl字段才能恢复.如果不知道原理就只能恢复数据库甚至重新 ...

  10. spark调优——Shuffle调优

    在Spark任务运行过程中,如果shuffle的map端处理的数据量比较大,但是map端缓冲的大小是固定的,可能会出现map端缓冲数据频繁spill溢写到磁盘文件中的情况,使得性能非常低下,通过调节m ...