vue 路由跳转、传参、新窗口打开页面

跳转方式

1、this.$router.push 当前页面跳转,新增history记录,点击后退,返回上一级页面

①参数直接拼接在后面:

this.$router.push('/nextPage?name=name&id=111')  // 当前页面跳转

接收参数:

this.$route.query // 全部参数

②路径写在name里面,params传参,这种方式前面不需要加‘/’

this.$router.push({ name: 'highcharts', params: { name: 111, id: 222 } })

使用:this.$route.params 接收参数

③ query传参 this.$route.query 接收参数

 this.$router.push({ path: "/highcharts", query: { username: "jack" } });

2、this.$router.replace('url?name=') // 替换history的最后一个页面,点击后退回到上上个页面,其他与this.$router.push基本一样

3、this.$router.go( );  

this.$router.go( -1 );  // 后退一步记录,等同于 history.back()
this.$router.go(1);  // 在浏览器记录中前进一步,等同于 history.forward()

新窗口打开页面

 let { href } = this.$router.resolve({
        path: "/highcharts",
        query: { username: "jack" }
      })
      window.open(href, '_blank')
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值