我想使用airbnb的eslint修改我的代码结构。我遵循了eslint-config-airbnb给出的这些指示。在启动命令npm run lint之后,结果由'fetch' is not defined和'localStorage' is not defined组成。
我已经看过这个github问题,但是仍然显示错误为相同的'fetch is not defined'。有什么解决办法吗。
发布于 2018-03-13 07:51:48
您可以使用.eslintrc配置globals文件。
将其添加到.eslintrc文件中。
"globals": {
"localStorage": true,
"fetch": true
}发布于 2018-11-25 21:27:31
不需要将其作为异常添加,只需将其添加到您的.eslintrc中,eslint就会知道它是什么:
"env": {
"browser": true
}发布于 2018-03-13 07:51:51
您可以尝试通过fetch对象访问localStorage和window。
window.fetch,window.localStorage
https://stackoverflow.com/questions/49250221
复制相似问题