簡體   English   中英

在react.js中使用eslint-config-airbnb時,“ fetch”是未定義的,“ localStorage”是未定義的

[英]“fetch” is undefined and “localStorage” is undefined , on using eslint-config-airbnb in react.js

我想使用airbnb的eslint修改我的代碼結構。 我已按照eslint-config-airbnb中給出的這些說明進行了操作 在啟動命令npm run lint ,結果'fetch' is not defined'fetch' is not defined 'localStorage' is not defined

我已經解決了這個github問題 ,但是仍然顯示錯誤,因為相同的'fetch is not defined' 有什么解決方案嗎?

您可以使用globals配置.eslintrc文件。

將此添加到您的.eslintrc文件。

"globals": {
        "localStorage": true,
        "fetch": true
    }

無需將其添加為例外,只需將其添加到您的.eslintrceslint就會知道它是什么:

  "env": {
    "browser": true
  }

您可以嘗試通過window對象訪問fetchlocalStorage

window.fetchwindow.localStorage

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM