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