function numToStr(num) { const numStr = num.toString(); // 没有指数就直接返回 if (!/e/.test(numStr)) return numStr; const nums = numStr.split(/\.|e/); // 判断是否有小数点 const hasDecimal = nums.length === 3; // 小数位数 const decimalCount = hasDecimal ? nums[1].length : 0; // 指数值 const powerCount = hasDecimal ? nums[2] : nums[1]; let fixCount = powerCount - decimalCount; fixCount = fixCount > 0 ? 0 : fixCount; return Number(num).toFixed(-fixCount) } numToStr(1.123e-10); // 0.0000000001123 numToStr(1.123e10); // 11230000000 numToStr(1.123e-3); // 0.001123 numToStr(2e-3); // 0.002 numToStr(112.3e-3); // 0.1123