'/'在angular中重新加载$state时,替换为url中的%252F

'/' replaced with %252F in url while reloading $state in angular

本文关键字:state %252F 中的 url 替换 angular 新加载 加载      更新时间:2023-09-26

我使用angularjs中的ui路由器进行路由。我有类似的url

www.example.com/*variable

其中变量具有word1/word2 的形式

因此url变为www.example.com/word1/word2

但是当我应用时

$state.reload(); or 
$state.go($state.current,{},reload:true);

前斜杠被%252取代,url变为

www.example.com/word1%252Fword2

为什么会发生这种情况,解决方案是什么?

您是否尝试将location设置为false?

$state.go($state.current,{},{reload:true, location: false});

由于您指定的是URL参数,所以它们可能是以URL编码的格式重新编写的。UI路由器文档状态

location布尔值或"replace"(默认为true(,如果为true将更新位置栏中的url,如果为false则不会。如果字符串"replace",将更新url并替换最后的历史记录。