The length of the addLocationMsg output by the nested output of the two for loops is 1. The following console.log('aaaaaa') is indeed output twice. Does anyone know what causes this problem? reason
The existing error is that undefined, location and zonesName are not initialized. The answer cannot be seen. It is recommended to use a browser to debug and see the values of these two properties. Whether it has not been initialized,
The problem has been solved. I thought that the locationList changes dynamically, so it should be placed in the outer loop. Moreover, there is a problem with the push, which causes an undefined to be pushed, so the following error appears
The existing error is that undefined, location and zonesName are not initialized. The answer cannot be seen. It is recommended to use a browser to debug and see the values of these two properties. Whether it has not been initialized,
You can output this.addLocationMsg before and after the loop to see what changes have occurred in its content. Just put a breakpoint and you will know
The problem has been solved. I thought that the locationList changes dynamically, so it should be placed in the outer loop. Moreover, there is a problem with the push, which causes an undefined to be pushed, so the following error appears
The last line, the looped object is changed during the loop
Did you use the vue framework?