interceptionStr(str) {/*判断字符串是否有小数,如果有只取后8位*/if (str === undefined || str === null || isNaN(str) || str === '') {return 0}str = String(str)let strSplitArr = [], first = null, strSecond = nullif (str.indexOf('.') != -1) { /*是否有小数*/strSplitArr = str.split('.')if (strSplitArr[1].length > 8) {strSecond = strSplitArr[1].slice(0, 8)first = strSplitArr[0]strSplitArr = `${first}.${strSecond}`} else {strSplitArr = str}} else {strSplitArr = str}return Number(strSplitArr)
}
详细解决方案
判断字符串是否有小数,如果有只取后几位
热度:0 发布时间:2024-02-27 21:02:47.0
相关解决方案