[Vuejs]-SetTimeout in Vue method not working

6👍

In the first case you are passing a function definition to setTimeout which will be executed once it is resolved.

In the second case you are directly executing the function, so you need to wrap the statement into a function:

setTimeout( () => this.emptyDivision('one'), 5000)

If emptyDivision returned a function then that function would be executed after the timeout and you wouldn’t need to wrap it.

Leave a comment