在開發中的一個需求,vue中關閉瀏覽器,
直接使用window.close()在chrome、fireFox會不起作用
需要改為一下方式
window.open('about:blank','_self').close()
上面這種方式會把你的當前頁面改為
或者使用
window.open('','_self').close(),
使用它的效果會比第一個更好
因此,比較合適的方法就是
var userAgent = navigator.userAgent;
if (userAgent.indexOf("Firefox") != -1 || userAgent.indexOf("Chrome") !=-1) {
window.open('','_self').close() 或
window.location.href = "about:blank"
}else {
window.opener = null;
window.open("about:blank", "_self");
window.close();
}
歡迎留言,請多多指導!!!