ToB企服应用市场:ToB评测及商务社交产业平台

标题: ESLint for...in 报错 [打印本页]

作者: 刘俊凯    时间: 2022-8-9 14:44
标题: ESLint for...in 报错
错误提示:for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.eslintno-restricted-syntaxThe body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype.eslintguard-for-in 
  1. for(const name in nameSet) {
  2. //code
  3. }
复制代码
将上述for...in循环改成
  1. Object.key(nameSet).forEach((name) => {
  2.        //code
  3. })
复制代码
错误消失

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4