没有受限的全局变量

JavaScript

Sam伽罗

2020-03-11

我正在使用React和Redux开发一个Web应用程序,当我开始我的项目时,我得到了这个:

Line 13:  Unexpected use of 'location'  no-restricted-globals

Search for the keywords to learn more about each error.

我搜索了很多有关如何解决它的方法,但是发现的答案都没有帮助我,所以我转向了堆栈溢出。

有人知道如何解决此错误吗?我感谢我能获得的所有帮助。

第706篇《没有受限的全局变量》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

3个回答
Pro伽罗 2020.03.11

尝试window在之前添加location(即window.location)。

村村阳光 2020.03.11

这是一个简单的方法,也许不是最好的解决方案,但是它可以工作。

在出现错误的行上方,粘贴以下代码:

// eslint-disable-next-line no-restricted-globals

GONear 2020.03.11
/* eslint no-restricted-globals:0 */

是另一种替代方法

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android