vue添加防斗

<Input style="width:200px" @on-change="saveAll" />
 export default {
  data(){
    return{
      timer: null, // 用于临时存放计时器
    }
  },
  methods: {
    saveAll () {
      if (this.timer) {
        clearTimeout(this.timer);
      }
      this.timer = setTimeout(() => {
        console.log("7895641536")
      }, 1000)
    }
  }
}
posted @ 2021-12-08 12:27  小万子呀  阅读(38)  评论(0)    收藏  举报