Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的代码现在只用空格替换第一个-,但是 url 中有多个-,我如何用空格替换所有?
-
window.location.hash.substring(1).replace('-', ' ');
尝试:
window.location.hash.substring(1).replace(/-/g, ' ')
g -> 所有实例