Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如果最小值为0,最大值为10000,step为10,当我拖动最右面的滑块再往右面的时候,显示10050 #1

Open
Max199909 opened this issue Jan 8, 2020 · 1 comment

Comments

@Max199909
Copy link

如果最小值为0,最大值为10000,step为10,当我拖动最右面的滑块再往右面的时候,显示10050

@zhangdaren
Copy link
Owner

zhangdaren commented Jan 10, 2020

收到,v1.0.11版本解决了此问题。
formatNumber修改成下面的代码即可。

	formatNumber(num, step) {   
			//格式化数字,保留几位小数   
			let stepStr = '' + step;   
			let index = stepStr.indexOf('.');   
			let len = index > -1 ? stepStr.length - index - 1 : 0;   
			let offestNum = parseInt(1 + Array(('' + len).length + 1).join(0)) * 0.1;   
			let tmpNum = num * offestNum;   
			return ((parseInt(tmpNum / step + (step > 1 ? 1 : step) * 0.5) * step) / offestNum).toFixed(len);   
		}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants