报错 Cannot read properties of undefined (reading 'forEach') 原因 使用 forEach 的对象不是 Array 类型,建议检查下代码。 解决方法 执行程序前做校验,或者使用默认值语法。 function arr(data: any[] = []) { data.forEach((e) => { ... }) }