新开页面跳转(重写open函数)
window.open({
path:'/member/info',
query:{
id:params.row.memberId
}}, '_blank');
window.open = (function (openView) {
return function (url, specs, replace) {
if (arguments[1] == "_blank" && typeof arguments[0] === "object") {
const { path, query, params } = arguments[0];
const urlResolve = this.$router.resolve({
path,
query,
params,
});
localStorage.setItem(window.location.origin + urlResolve.href, window.location.href);
window.open(urlResolve.href, "_blank", "", false);
}
openView(url, specs, replace);
};
})(window.open);
返回
this.$router.go(-1)
this.$router.go = (function (go) {
return function (n) {
if (window.history.length <= 1) {
if (localStorage.getItem(window.location.href)) {
window.open(localStorage.getItem(window.location.href), "_self");
} else {
this.$router.push({ path: "/" });
}
return false;
}
go(n);
};
})(this.$router.go);