javascript - nested for loop
漂亮男人
漂亮男人 2017-05-19 10:09:39
0
5
533


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

漂亮男人
漂亮男人

reply all(5)
漂亮男人

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?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template