当输入框为空的时候设置复选框选择无效

在这里插入图片描述
这个功能主要实现思路是使用定时器来延时控制,代码如下:

watch: {

    //条件控制复选框的状态
    checked: {
      handler() {
        if(this.checked == false) this.$message.warning('未连接或者时隔为空');
        if(this.start_wb == false || this.time == ''){
          setTimeout(()=>{ this.checked=false; clearTimeout(this.setTimeout);},100)
        }else {
          if(this.checked == true) {
            //根据复选框的值决定是否开启定时发送功能
            this.timeflag = true
            this.autoSend()
          }else {
            clearTimeout(this.timer);  //清除延迟执行
            this.timeflag = false;
          }
        }
      }
    },
  }
posted @ 2022-09-10 11:12  Little_Monster-lhq  阅读(22)  评论(0编辑  收藏  举报