【问题标题】:Uncaught TypeError: Cannot read properties of undefined (reading 'forEach') (using Parcel )Uncaught TypeError: Cannot read properties of undefined (reading 'forEach') (using Parcel)
【发布时间】:2021-09-08 08:52:36
【问题描述】:
['hashchange' &&'load'].forEach(ev => 
window.addEventListener(ev, controlRecipes))

// window.addEventListener('hashchange', controlRecipes)
// window.addEventListener('load', controlRecipes)

以下是 CL 的输出

controller.js:37 Uncaught TypeError: Cannot read properties of undefined (reading 'forEach') 在 Object.jKMjS../model.js (controller.js:37) 在 newRequire (index.436439df.js:71) 在 index.436439df.js:120 在 index.436439df.js:143

【问题讨论】:

  • 如果它解决了您的问题,请将其标记为已回答

标签: javascript parceljs


【解决方案1】:

删除&& 并添加,forEach 用于遍历数组。参考forEach

【讨论】:

    猜你喜欢
    • 2021-11-10
    • 2022-01-11
    • 1970-01-01
    • 1970-01-01
    • 2022-10-09
    • 2022-07-21
    • 2022-07-22
    • 2022-09-26
    • 2022-01-06
    相关资源
    最近更新 更多