Vue价格四舍五入保留两位和直接取两位

价格四舍五入保留两位

     

filters:{
     formatPrice:function(value){
          let tempVal = parseFloat(value).toFixed(3)
          let realVal = tempVal.substring(0,  tempVal.length - 1)
                return realVal
            }
     }

   直接取两位

     

filters: {

  formatPrice(value) {

  // 截取当前数据到小数点后两位

    let realVal = parseFloat(value).toFixed(2)

    return realVal

  }

}
原文地址:https://www.cnblogs.com/zyydt/p/10730797.html