gpt4 book ai didi

reactjs - react => 未捕获的 URIError : This is likely caused by an invalid percent-encoding. 修复

转载 作者:行者123 更新时间:2023-12-04 13:02:30 25 4
gpt4 key购买 nike

正在 react 中工作,然后遇到了类似的问题

  Uncaught URIError: This is likely caused by an invalid percent-encoding

我目前正在使用新闻 API,其中一些文章可能包括 % .我的整个应用程序依赖于在 url 中显示新闻文章名称,因为我使用的是 this.props.match.params.id
我试图在线搜索解决方案,但在解决这个确切问题时,大多数人都不清楚。

这个问题有简单的解决方法吗?

最佳答案

您需要使用 encodeURIComponent()使用您收到的路径作为参数:
例子:

const receivedArticleName = encodeURIComponent('Article Name with %');

由于您正在使用 API,因此一旦您收到它,请使用该 receivedArticleName 设置您的 URL 变量,然后您就完成了。

关于reactjs - react => 未捕获的 URIError : This is likely caused by an invalid percent-encoding. 修复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52343328/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com