简体   繁体   English

使用for in循环时出现Eslint错误如何重组

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

I am getting 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 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 error when using the following line of code 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;
      }

How can I restructure the code to remove this error Thanks如何重组代码以消除此错误谢谢

Try this:尝试这个:

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