使用带有正斜杠的pushState(using pushState with forward slashes)

编程入门 行业动态 更新时间:2024-10-27 08:36:26
使用带有正斜杠的pushState(using pushState with forward slashes)

我有以下推送状态:

history.pushState(null, null, 'category/item');

而项目是动态替换的。

现在,这用于点击我的菜单链接。 第一次pushState很好地工作并重写url。 但之后它不再起作用了。

为什么pushState有正斜杠的问题?

有没有办法在其中使用带斜杠的字符串? 或者我必须以某种方式逃脱它们?

我对这个问题感到很疯狂

谢谢你的帮助

I have the following push state:

history.pushState(null, null, 'category/item');

whereas item is replaced dynamically.

Now this is used on click of my menu links. The first time the pushState works nicely and rewrites the url. But after that it doesn't work anymore.

Why does pushState have problems with forward slashes ?

Is there a way to use strings with slashes in them ? Or do I have to escape them somehow ?

I'm going crazy with this issue

Thank for helping out

最满意答案

好的,所以我很愚蠢到没有在新网址之前放一个正斜杠。 这导致pushState不能很好地路由到root。使用斜杠它可以很好地工作

Ok so I was stupid enough to just not put a forward slash before the new url. This caused the pushState to not route to the root nicely With the slash it works nicely

更多推荐

本文发布于:2023-07-22 01:00:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1215500.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:斜杠   pushState   slashes

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!