在我的代码中,我分配了以下内容:
window.location.href = "www.example.com/test";
但是当页面实际加载时,浏览器 URL 是 www.example.com/test/www.example.com/test
。我没有向 URL 附加任何内容,而且我不确定它是如何再次附加 URL 的。
最佳答案
我认为您遗漏了“http”或“https”部分。您是否尝试过以下方法?
window.location.href = "https://www.example.com/test";
或
window.location.href = "http://www.example.com/test";
关于javascript - 为什么 window.location.href 再次附加 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46333555/