jsは値が特定の範囲内にあるかどうかを判断します。範囲は[1,2](0,3)のようなものです。

 使用する場合は以下の形式で呼び出す必要があります

this.compareArea({ name: [1,2] }, 2)
    compareArea(data, num) {
      if (data.name == "") {
        return true;
      }
      var smallValue = parseInt(
        data.name.split(",").shift().split("[").pop().split("(").pop()
      );
      if (data.name.split(",").shift().indexOf("(") != -1) {
        smallValue += 0.01;
      }
      var bigValue = parseInt(
        data.name.split(",").pop().split("]").shift().split(")").shift()
      );
      if (data.name.split(",").pop().indexOf(")") != -1) {
        bigValue -= 0.01;
      }
      if (isNaN(bigValue)) {
        if (smallValue <= num) {
          return true;
        }
        return false;
      } else {
        if (smallValue <= num && bigValue >= num) {
          return true;
        }
        return false;
      }
    },

おすすめ

転載: blog.csdn.net/weixin_45294459/article/details/127065382