Javascript 没有受限制的全局变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44991656/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
No restricted globals
提问by Martin Nordstr?m
I am using React and Redux to develop a webapp and when I started up my project I got this:
我正在使用 React 和 Redux 来开发一个 webapp,当我开始我的项目时,我得到了这个:
Line 13: Unexpected use of 'location' no-restricted-globals
Search for the keywords to learn more about each error.
I search a lot about how to resolve it, but none of the answers I found helped me, so I turned to Stack overflow.
我搜索了很多关于如何解决它的方法,但我找到的答案都没有帮助我,所以我转向了堆栈溢出。
Does anyone know how to fix this error? I appreciate all the help I can get.
有谁知道如何解决这个错误?我很感激我能得到的所有帮助。
回答by Chasen Bettinger
Try adding windowbefore location(i.e. window.location).
尝试添加window之前location(即window.location)。
回答by Martin Nordstr?m
This is a simple and maybe not the best solution, but it works.
这是一个简单的,也许不是最好的解决方案,但它有效。
On the line above the line you get your error, paste this:
在您收到错误的行上方的行中,粘贴以下内容:
// eslint-disable-next-line no-restricted-globals
// eslint-disable-next-line no-restricted-globals
回答by Dan Krueger
/* eslint no-restricted-globals:0 */
is another alternate approach
是另一种替代方法

