[Vuejs]-Line in vue.js function executed before the previous ended

0👍

It seems that dat.toImage() is an asynchronous method, so Javascript start executing next method while this is not yet done. If this is your own method, you can return a promise from this function and on resolve of this promise invoke your second method.

0👍

Try adding this.$refs.my_form.submit() in a setTimeout function. A small tricky workaround.

  submit_form: function () {
    this.drawing = dat.toImage();
    setTimeout(() => {
      this.$refs.my_form.submit()
    }, 3000)    
  }
}```

Leave a comment