redirect [重定向]
重定向到指定的 URL。
使用 window.location.href
or window.location.replace()
重定向到 url
.
传递第二个参数以模拟链接单击 (true
- default) 或 HTTP 重定向 (false
).
const redirect = (url, asLink = true) =>
asLink ? (window.location.href = url) : window.location.replace(url);
redirect("https://google.com");