vue中提交由于页面卡顿或连续点击出现重复提交现象

在data中定义一个变量

data(){
  return{
    repeat:true
  }
}
methods:{
  isRepeat(){
      if(!this.repeat){ return }
      this.repeat = false;
      // 发送axios请求
      this.$axios.post("url",{})
      .then(res=>{
        // 请求成功改变repeat的值
        this.repeat = true
      })
      .catch(err=>{
        // ...
      })
  }
}
posted @ 2021-07-06 15:21  WJJ呀  阅读(311)  评论(0)    收藏  举报