Add 4 digits 0 to the end of the integer, if there is a decimal not enough 4 digits, add 0 to the rest

    <el-table-column label="合同金额(万元)" align="center" prop="money">
          <template slot-scope="scope">
            {
   
   {filterPoint(scope.row.money,4)}}
          </template>
     </el-table-column> 
    /*处理保留4位小数的问题*/
    filterPoint (number, n) {
      n = n ? parseInt(n) : 0;
      if (n <= 0) {
        return Math.round(number);
      }
      number = Math.round(number * Math.pow(10, n)) / Math.pow(10, n); // 四舍五入
      number = Number(number).toFixed(n); // 补足位数
      return number;
    },

 

Guess you like

Origin blog.csdn.net/qq_40055200/article/details/112966486