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
相关产品推荐
相关产品推荐

