須要在異步調用接口前,先打開新窗口;異步
在接口返回後,若是肯定須要打開新窗口,則設置窗口的 href 地址;this
若是不須要,則關閉窗口便可。url
如:接口
let newWin = window.open('') this.singleVisit(url, function (toUrl) { if (toUrl) { newWin.location.href = toUrl } }, function () { newWin.close() })這樣能解決問題。