须要在异步调用接口前,先打开新窗口;异步
在接口返回后,若是肯定须要打开新窗口,则设置窗口的 href 地址;this
若是不须要,则关闭窗口便可。url
如:接口
let newWin = window.open('') this.singleVisit(url, function (toUrl) { if (toUrl) { newWin.location.href = toUrl } }, function () { newWin.close() })这样能解决问题。