您的位置:首页 > Web前端 > Vue.js

vue 打开新窗口传参以及新窗口接受参数

2019-07-26 11:44 1726 查看

主体页面代码:

[code]<div class="open" @click="open()">打开新窗口带参数</div>
[code]  methods: {
open () {
const {href} = this.$router.resolve({
path: '/novelList',
query: {
pdf: 77
}
})
window.open(href, '_blank')
}
}

新窗口页面接受参数:

[code] created() {
this.getParams();
},
methods: {
getParams() {
// 取到路由带过来的参数
const routerParams = this.$route.query.pdf;
console.log("接受的pdf的值:", routerParams);
}
}

注意: “const routerParams = this.$route.query.pdf;”,中的pdf与主体页面query中的pdf一致;

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: