export default {
data() {
return {
jumpUrl: '',
newWin: null // 新窗口的引用
}
},
watch: {
url(newVal, oldVal) {
if(newVal && this.newWin) {
this.newWin.sessionStorage.clear()
this.newWin.location.href = newVal;
this.jumpUrl = '';
this.newWin = null;
}
}
},
methods: {
clickHandle() {
let _this = this;
// 先打开一个空的新窗口,再请求
this.newWin = window.open();
api.get('xxx', params).then(response => {
let data = response.data;
if(data.code === 0 ) {
_this.jumpUrl = data.data.url || '';
}
});
}
}
}