[英]How to fix eslint errors in javascript code
for (const [key, value] of Object.entries(attrs)) {
element.setAttribute(`${key}`, `${value}`);
}
}
我在我的代碼中使用它,它用於 select 鍵盤的鍵值,但 eslint 顯示了一些錯誤
error 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 no-restricted-syntax
正如@dork 在他的評論中正確指出的那樣,( eslint
建議)你不應該使用for... of
循環。 它在舊瀏覽器中不受支持,可能需要一個 polyfill ( regenerator-runtime
)。
最好這樣寫你的代碼:
Object.entries(attrs).forEach(([key, value]) => element.setAttribute(key, value));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.