a page jumps to b page
The code under the previous page (page a) that did not jump:
const {
href } = this.$router.resolve({
name: 'contentArticle', //需要打开的新页面vue的名字
query: {
id: id //携带的参数,多个使用,隔开
}
});
window.open(href, "_blank");//跳转
The code under the new page (page b) that needs to be jumped to
data() {
return {
id: '',
};
},
created(){
this.getParams();
},
methods: {
getParams () {
// 取到路由带过来的参数
var routerParams = this.$route.query.id;
// 将数据放在当前组件的数据内
this.id = routerParams;
},
}
watch: {
// 监测路由变化,只要变化了就调用获取路由参数方法将数据存储本组件即可
'$route': 'getParams'
}