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

好了,如果有不懂的问题,可以关注我的个人微信公众号和我交流

猜你喜欢

转载自blog.csdn.net/u012118993/article/details/108627160