You need to enable JavaScript to run this app. React项目报'decodeUriComponent' is not defined no-undef错误如何修复
优惠活动
大模型
产品
解决方案
定价
更多

React项目报'decodeUriComponent' is not defined no-undef错误如何修复

报错修复方案

该错误由方法名拼写错误导致:JavaScript 内置的全局URL解码方法为 decodeURIComponent,你代码中写的 decodeUriComponent 大小写不符合规范,因此ESLint触发no-undef未定义变量报错。该方法属于浏览器原生全局API,无需额外导入任何依赖。

具体修改方式

  • 定位到getTokenFromUrl方法内的对应代码行:
initial[parts[0]] = decodeUriComponent(parts[1]);
  • 将方法名修正为正确拼写即可:
initial[parts[0]] = decodeURIComponent(parts[1]);

注意方法名中URI三个字母均为大写,末尾Component的首字母C也为大写,修正后重新运行项目即可消除报错。

内容的提问来源于stack exchange,提问作者furkanayilmaz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.08 17:54:04