84669 Lernen von Personen
152542 Lernen von Personen
20005 Lernen von Personen
5487 Lernen von Personen
7821 Lernen von Personen
359900 Lernen von Personen
3350 Lernen von Personen
180660 Lernen von Personen
48569 Lernen von Personen
18603 Lernen von Personen
40936 Lernen von Personen
1549 Lernen von Personen
1183 Lernen von Personen
32909 Lernen von Personen
设置了 window.location.hash=“abc”后,url后面自动加上了“#abc”。这时候要怎么设置才能把“#abc”去掉呢?设置hash=“”只能去掉“abc”,还会残留一个#
学习是最好的投资!
history api(只支持现代浏览器)
history.replaceState(null,'',location.pathname+location.search);
location.replace(导致页面重新加载)
location.replace(location.pathname+location.search);
location.hash 本来就是指 URL 里 # 符号及其后的部分,如果你是要做路由映射并且不想用基于 hash 的方案,那你应该考虑 HTML5 的 History API。不过这个是要考虑向后兼容的,部署上也会要做一些配置才能正常工作。
location.hash
#
delete location.hash
history api(只支持现代浏览器)
location.replace(导致页面重新加载)
location.hash
本来就是指 URL 里#
符号及其后的部分,如果你是要做路由映射并且不想用基于 hash 的方案,那你应该考虑 HTML5 的 History API。不过这个是要考虑向后兼容的,部署上也会要做一些配置才能正常工作。delete location.hash