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
漂亮男人2017-05-19 10:11:39
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,
巴扎黑2017-05-19 10:11:39
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
迷茫2017-05-19 10:11:39
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