你没有正确使用
Location
:
假设你想使用 vanilla JS:
如果你想模拟某人点击链接,使用
location.href
如果要模拟 HTTP 重定向,请使用
location.replace
例子:
// similar behavior as an HTTP redirect
window.location.replace("http://stackoverflow.com"); // or "/redirect.html"
// similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com"; // or "/redirect.html"