vue router 跳转到新的窗口方法

在CreateSendView2.vue 组件中的方法定义点击事件,vue router 跳转新的窗口通过采用如下的方法可以实现传递参数跳转相应的页面
goEditor: function (index,channel) {
//跨域的方法传递参数(参见
let routeData = this.$router.resolve({path: '/createImageText2', query: {ID: index,channel:channel}});
window.open(routeData.href, '_blank');
注:1、let routeData = this.$router.resolve({path:`/createImageText2/${ID,channel}`)这样传递不了参数需要使用上面的方法
2、_blank是表示开一个新窗口

在PreviewImageText.vue组件页面中通过created()生命函数接收CreateSendView2.vue组件传递地参数id,channel,在该组件中data中定义变量来接收
created(){
this.preImgMsgDTO.channel=this.$route.query.channel
this.preImgMsgDTO.id=this.$route.query.ID

}

query,和params的区别

1、用法

   A、query要用path来引入,接收参数都是this.$route.query.name。

B、params要用name来引入,接收参数都是this.$route.params.name。

2、效果

A、query类似于ajax中get传参,即在浏览器地址栏中显示参数。

B、params则类似于post,即在浏览器地址栏中不显示参数。

3、个人建议

在路由传参上建议使用params,以隐藏参数,做好安全保密。



转载于:https://www.cnblogs.com/zhx119/p/9812991.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值