window.open此方法在safari浏览器下,会被自动阻止拦截,解决方法有两种,亲测两种都有效,Vue2的项目:
方案一:ajax或者axios请求之前打开一个初始化窗口,没有url地址的,请求完成后直接赋值location地址
var adPopup = window.open('about:blank', '_blank', 'width=' + window.screen.width + ', height=' + window.screen.height + ', ...')
doQuery().then(response => {
Message.success("成功");
adPopup.location = response.url;
})
方案二:使用setTimeout
doQuery().then(response => {
Message.success("成功");
setTimeout(() => {
var adPopup = window.open('about:blank', '_blank', 'width=' + window.screen.width + ', height=' + window.screen.height + ', ...')
adPopup.location = response.url;
}, 500)
})