The first argument to the method is the number to convert and the second argument is the number of decimal places to preserve

export function tranNumber(num, point) { if (num === undefined || num === null) { return 0; } // Convert a number to a string, then use the split method. Split, 0 const numStr = num.toString().split('.')[0]; If (numStr. Length < 5) {return numStr; if (numStr. Length < 5) {return numStr; } else if (numstr. length >= 5 && numstr. length <= 8) {// If the number is greater than 6 digits and less than 8 digits, add ten thousand const decimal = numStr.substring(numStr.length - 4, numStr.length - 4 + point); / / by one thousand, one hundred a number of return ` ${parseFloat (` ${parseInt (` ${10000} num / `)}. ${decimal} `)} wan `; } else if (numstr.length > 8) {// Add 100 million const decimal to number greater than 8 bits = numstr.substring (numstr.length -8, numStr.length - 8 + point); Return ` ${parseFloat (` ${parseInt (` ${100000000} num / `)}. ${decimal} `)} $`; }}Copy the code