Javascript 如何在不重新加载页面的情况下更改url浏览器的一部分?

Javascript 如何在不重新加载页面的情况下更改url浏览器的一部分?,javascript,Javascript,我有这样一个url: http://localhost:4200/activar_cuenta/5sadaaeasdas 如何将我的url更改为http://localhost:4200/是否重新加载页面?仅更改浏览器url 谢谢试试这个: window.history.pushState(null, '', '/'); 试试这个: window.history.pushState(null, '', '/'); 您使用的是Angular还是Pure Js?您使用的是Angular还是Pu

我有这样一个url:

http://localhost:4200/activar_cuenta/5sadaaeasdas
如何将我的url更改为
http://localhost:4200/
是否重新加载页面?仅更改浏览器url

谢谢

试试这个:

window.history.pushState(null, '', '/');
试试这个:

window.history.pushState(null, '', '/');

您使用的是Angular还是Pure Js?您使用的是Angular还是Pure Js?