In the Vue calculation property, what happens when an array object uses the map function to report an error?

A calculation property code in the vue component relies on another calculation property projectPath (which has only array or undefined values), but calls map in code"s calculation function and reports

TypeError: this.projectPath.map(...) is not a function
< H2 > what is the reason for this? < / H2 >

Code:

   

May.18,2022

your error report says pathList while your printout is projectPath .

you should see if pathList is null or undefined .


I tricked myself for half an hour. An error was written elsewhere, causing the vue not to be updated automatically. Here there should be a problem with the old code, but there is no update after correction, resulting in a mismatch between the code and the error report.


because your projectPath initial value is not an array, there is no map method on his prototype.

you can read this article https://blog.csdn.net/wxl1555...

Menu