Skip to content

Commit

Permalink
fix(Counter): 修复浮点数数值超出问题
Browse files Browse the repository at this point in the history
  • Loading branch information
7yue committed May 18, 2022
1 parent ac56e8a commit dfcd6ba
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/counter/index.js
Expand Up @@ -114,6 +114,9 @@ Component({
} else if (type === 'reduce') {
result = count - step < min ? min : count - step;
}
// 浮点数运算会有精确度问题,保留两位小数

This comment has been minimized.

Copy link
@dubaiyouyue

dubaiyouyue May 30, 2022

123

result = result.toFixed(2);
result = parseFloat(result);

this.setData({ count: result });
eventUtil.emit(this, 'lintap', {
Expand Down

0 comments on commit dfcd6ba

Please sign in to comment.