Cannot read properties of undefined (reading ‘forEach‘)

report error

 Cannot read properties of undefined (reading 'forEach')

reason

forEachThe object used is not Arrayof type, it is recommended to check the code.

Solution

Validate before executing the program, or use the default value syntax.

function arr(data: any[] = []) {
    
    
  data.forEach((e) => {
    
    
    ...
  })
}

Guess you like

Origin blog.csdn.net/m0_53808238/article/details/129796820
Recommended