interceptionStr(str) {/*判断字符串是否有小数,如果有只取后8位*/ if (str === undefined || str === null || isNaN(str) || str === '') { return 0 } str = String(str) let strSplitArr = [], first = null, strSecond = null if (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) }
判断字符串是否有小数,如果有只取后几位
最新推荐文章于 2024-05-16 10:47:08 发布