Prevent repeated submission of forms (front end)

When the interface response is slow, prevent the form from being submitted repeatedly

<button class="submit-btn" @click="submit">发送</button>

isLock: false, //防止频繁点击

submit() {
     if (this.isLock)  return
      this.isLock = true
      addAnswer(this.form).then(res => {
           this.isLock = false
      }).catch(() => {
           this.isLock = false
      })
}

Guess you like

Origin blog.csdn.net/weixin_46324536/article/details/129589744