obj[val] = obj[val].replace(/^\D*([1-9]\d*\.?\d{0,3})?.*$/,'$1');

想要小数点后几位就把这个数字改为几

 @keyup.native="checkNumber('expenseBillAmount',scope.row)" @blur="checkNumberAgain('expenseBillAmount',scope.row)"
 checkNumber(val,obj) {
      obj[val] = obj[val].replace(/^\D*([0-9]\d*\.?\d{0,3})?.*$/,'$1');
    },
    checkNumberAgain(val,obj){
      if(obj[val]){
          if(Number(obj[val]) === 0){
          this.$message({
            message: "非法数值",
            type: "warning"
          });
          obj[val] = null;
          return ;
        }
        obj[val] = obj[val].replace(/^\D*([0-9]\d*\.?\d{0,3})?.*$/,'$1');
      }
    },

 

 

Logo

前往低代码交流专区

更多推荐