vue3写一个范围值

96 阅读1分钟

第一步

<a-form-item style="display: flex">
    <a-input-number
       v-model:value="where.MIN"
       style="width: 109px;"
       :min="0"
       @change="eMinChange"
       placeholder="请输入最小范围"
  />
~
<a-input-number
   v-model:value="where.MAX"
   style="width: 108px;"
   :min="0"
   @change="MaxChange"
   placeholder="请输入最大范围"
/>
</a-form-item>

然后在methods中

// 最小值
    MinChange() {
      this.verification();
    },
    // 最大值
    MaxChange() {
      this.verification();
    },
    //字段验证
    verification() {
      if (this.queryParam.MIN > this.queryParam.MAX) {
        // console.log(111);
        this.$message.warning('起始数不能大于结束数');
        return false;
      } else {
        return true;
      }
    },
    searchQuery() {
      if (this.verification()) {
        this.loadData(1);
      } else {
        this.$message.warning('起始数不能大于结束数');
      }
    },