简体   繁体   English

如何在不更改页面的情况下编辑 URL?

[英]How can I edit the URL without changing pages?

I want to edit the URL of the page without changing to another.我想编辑页面的 URL 而不更改为另一个。 Something like this:像这样的东西:

For Example: Original URL: localhost:3000/sagsdfgs
             New URL: localhost:3000/fgdgs

Same Host, different URL, same page.相同的主机,不同的 URL,相同的页面。 I think in react-router-dom there is a function, but I don't remember what the function is called and I looked for it but I didn't find it我认为在 react-router-dom 中有一个函数,但我不记得该函数被称为什么,我寻找它但我没有找到它

Try out !试用 !

let url = window.location.toString();
window.location = url.replace(/function=login/, '/function=userloggedIn/');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM