簡體   English   中英

使用for in循環時出現Eslint錯誤如何重組

[英]Eslint error when using the for in loop how to restructure

我得到iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations錯誤

 const errors = {};
      for (const i of err.inner) {
        errors[i.path] = i.message;
      }

如何重組代碼以消除此錯誤謝謝

嘗試這個:

let errors = {};

err.inner.forEach(item => {
   errors[item.path] =  item.message;
});

暫無
暫無

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

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