From e33c040aa8207960f518f698f8a7fe9c6b5a0175 Mon Sep 17 00:00:00 2001 From: yang <30883395+webvs2@users.noreply.github.com> Date: Wed, 16 Nov 2022 00:07:36 +0800 Subject: [PATCH] =?UTF-8?q?Statistic=EF=BC=9AFixed=20the=20thousandth=20bi?= =?UTF-8?q?t=20bug=20(#22252)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * statistic:Fixed the thousandth bit bug statistic:Fixed the thousandth bit bug * Modifying Spaces Modifying Spaces --- packages/statistic/src/main.vue | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/statistic/src/main.vue b/packages/statistic/src/main.vue index 92e7585f0..220865cab 100644 --- a/packages/statistic/src/main.vue +++ b/packages/statistic/src/main.vue @@ -102,7 +102,6 @@ export default { }, methods: { branch() { - // console.log('timeIndices', this.timeIndices); if (this.timeIndices) { clearInterval(this.timeTask); this.countDown(); @@ -110,12 +109,13 @@ export default { this.dispose(); } }, - - magnification(num, mulriple = 1000, groupSeparator = ',') { // magnification factor - if (_.isNumber(num)) return false; - let result = String(_.divide(num, mulriple)) - .split('.') - .join(groupSeparator || ','); + magnification(num, _mulriple = 1000, _groupSeparator = ',') { // magnification factor + const level = String(_mulriple).length - 1; + const reg = new RegExp(`\\d{1,${level}}(?=(\\d{${level}})+$)`, 'g'); + const result = String(num) + .replace(reg, '$&,') + .split(',') + .join(_groupSeparator); return result; }, dispose() { @@ -192,7 +192,6 @@ export default { return (result); }; this.timeTask = setInterval(function() { - // console.log(diffTiem); if (disappearTime(diffTiem)) clearInterval(than.timeTask); diffTiem = diffTiem < REFRESH_INTERVAL ? 0 : diffTiem - REFRESH_INTERVAL; than.disposeValue = formatTimeStr(format, diffTiem);