el-input 输入0-100 的数字保留两位小数

html

 

js

tradeLvInput(value) {
      if (+value >= 100) {
        this.tradeLv = 100;
        return;
      }
      this.tradeLv = value
        .replace(/^\D*(\d*\.?\d{0,2})?.*$/, "$1")
        .replace(/^(\d{0,2})?\d*$/, "$1");
    }

你可能感兴趣的:(javascript,java,servlet)