码迷,mamicode.com
首页 > Web开发 > 详细

vue 带参数跳转打开新窗口 $router.resolve 参数不在url中

时间:2020-06-05 16:48:12      阅读:439      评论:0      收藏:0      [点我收藏+]

标签:query   url   列表   class   nbsp   item   href   open   out   

如果参数在路径中:
router.js
    path: ‘/project/:id‘

var { href } = this.$router.resolve({
    path: ‘/project‘,
    query: {
        id: this.id
    }
});
window.open(href);

获取参数:this.$route.query.id

如果参数不在路径中:
1.不打开新窗口:
     path: ‘/projectlist‘ , name: ‘项目列表‘        

    var href = this.$router.push({
    name: ‘项目列表‘,
    params: {
       msg : this.msg
    }
});
获取参数:this.$route.params.msg
1.打开新窗口:
     

var { href } = this.$router.resolve({
    name: ‘项目列表‘,
});
localStorage.setItem("msg", this.msg)
window.open(href);
获取参数:
if (localStorage.getItem(‘msg‘)){
      this.m= localStorage.getItem(‘msg‘);
      localStorage.clear();
};

 

vue 带参数跳转打开新窗口 $router.resolve 参数不在url中

标签:query   url   列表   class   nbsp   item   href   open   out   

原文地址:https://www.cnblogs.com/liuliu-/p/13050545.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!