SOURCE

function formatBigNumber(targetNumber,fixedNumber=2){
    if(typeof targetNumber!="number"||typeof fixedNumber !='number'){
        return 0;
    }
    let zoreDecimalNumberStr = ''
    if(fixedNumber>0){
        for(let i = 0;i<fixedNumber;i++){
            zoreDecimalNumberStr+="0"
        }
    }
    // 亿 或 亿以上
    if(targetNumber.toString().length>8){
        // 10000 0000
        console.log(zoreDecimalNumberStr)
        console.log((targetNumber/100000000))
        const decimalNumberStr = (targetNumber/100000000).toString().split('.')[1]
        const integerNumberStr =  (targetNumber/100000000).toString().split('.')[0]
        console.log(decimalNumberStr)
        return zoreDecimalNumberStr==decimalNumberStr.substr(0,fixedNumber)?(targetNumber/(100000000)).toFixed(0)+'亿':(targetNumber/(100000000)).toFixed(fixedNumber)+'亿'
    }
}

 function _tranNumber(num, point) {
      let numStr = num.toString().split('.')[0];
      console.log(numStr)
      if (numStr.length < 6) {
        return numStr
      } else if (numStr.length >= 6 && numStr.length <= 8) {
        //获取的是变成万 后的小数位
        let decimal = numStr.substring(numStr.length - 4, numStr.length - 4 + point)
        return parseFloat(parseInt(num / 10000) + '.' + decimal) + "万"
      } else if (numStr.length > 8) {
        let decimal = numStr.substring(numStr.length - 8, numStr.length - 8 + point) //获取小数点
        
        return parseFloat(parseInt(numStr / 100000000) + "." + decimal) + "亿"
      }
    }
console.log(_tranNumber("12124142",2))
console.log(_tranNumber(12124142,2))
// console.log(formatBigNumber(1000000000))
console 命令行工具 X clear

                    
>
console