const isIE = !!window.ActiveXObject || "ActiveXObject" in window;
// debugger
if (isIE) {
// debugger
let iframeEle = document.createElement("iframe");
iframeEle.src =
process.env.VUE_APP_CAS +
"?service=" +
process.env.VUE_APP_API +
"/auth/queryUser";
// debugger
iframeEle.style.width = "0px";
iframeEle.style.height = "0px";
iframeEle.onload = function() {
// next();
getUsers()
.then(res => {
// 请求成功后cookies设置userInfoView
window.sessionStorage.setItem(
"userInfoView",
JSON.stringify(res)
);
// alert(' res.userName'+ res.userName)
store.dispatch("changeUserName", res.userName);
store.dispatch("changeUserPhone", res.phoneNumber);
store.dispatch("changeUserMail", res.email);
document.body.removeChild(iframeEle);
to.query.login = 2;
next();
})
.catch(err => {
// next();
});
store.dispatch("setHistory", to.query.id);
};
document.body.appendChild(iframeEle);
跨域之后session会丢失,导致请求总是请求不到,ie下出现请求死循环,解决方案是创建iframe 在src里输入查询请求实现sessIon的共享,之后再发送请求,删除iframe dom结构