vue 帶參數跳轉打開新窗口 $router.resolve 參數不在url中


如果參數在路徑中:
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();
};

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM