我在执行时收到Typescript错误错误错误如下所示:
TypeError: Cannot read properties of undefined (reading 'forEach')
at ScapprovalPaymentEventComponent.<anonymous> (http://localhost:50000/main.js?v=23.1.0+Build-17.02-1904:6102:33)
at step (http://localhost:50000/main.js?v=23.1.0+Build-17.02-1904:5940:23)
at Object.next (http://localhost:50000/main.js?v=23.1.0+Build-17.02-1904:5921:53)
at http://localhost:50000/main.js?v=23.1.0+Build-17.02-1904:5915:71
at new ZoneAwarePromise (http://localhost:50000/polyfills.js?v=23.1.0+Build-17.02-1904:8553:29)
at push../ClientApp/app/components/forms/scapproval-payment-event/scapproval-payment-event.component.ts.__awaiter (http://localhost:50000/main.js?v=23.1.0+Build-17.02-1904:5911:12)
at push../ClientApp/app/components/forms/scapproval-payment-event/scapproval-payment-event.component.ts.ScapprovalPaymentEventComponent.initializeControls (http://localhost:50000/main.js?v=23.1.0+Build-17.02-1904:6058:16)
这就是代码:
this.totalCount = response.total_rows;
this.bookmark = response.bookmark;
if (isPaginationCall && this.approvedForms && this.approvedForms.length > 0) {
paymentForms.forEach(x => this.approvedForms.push(x));
} else {
this.approvedForms = paymentForms;
}
this.onShowRecordChange();
setTimeout(() => {
this.spinner.hide("MONITORPAYMENT");
}, 0);
1条答案
按热度按时间jckbn6z71#
你可以对数组使用
.forEach
方法。当您尝试将.forEach
方法与数组以外的其他数据结构一起使用时,会显示此错误。