js 保留两位小数

保留两位小数通用方法

// 金额格式化保留2位小数 2 -> 2.00  2.1 -> 2.10
function getFDataFixed (source, length = 2) {
  return (+String(source)).toFixed(length) // +String(source) 字符转数字
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章