[Vuejs]-Browser get stuck when running loop in mounted()

1πŸ‘

Is something in my loop?

Yes: You never change this.id in the loop. That loop just creates HTTP request after HTTP request after HTTP request, because your increment of this.id is inside your then callback, which is asynchronous.

Move the increment outside of the then callback so the loop actually finishes.


Re your edit replacing while (this.id <= 10) with while (this.found), it’s the same sort of problem: Nothing ever sets this.found.

πŸ‘€T.J. Crowder

Leave a comment