mirror of https://github.com/layui/layui
优化 input 数字输入框组件的小数点后保留位逻辑
parent
ec2bddd27b
commit
0b7577099c
|
@ -293,10 +293,11 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
||||||
if(value < min) value = min;
|
if(value < min) value = min;
|
||||||
if(value > max) value = max;
|
if(value > max) value = max;
|
||||||
|
|
||||||
// 保留位数
|
// 小数点后保留位数
|
||||||
value = value.toFixed(function(step){
|
var fixed = function(step){
|
||||||
return (step.match(/(?<=\.)[\d]+$/) || [''])[0].length;
|
return (step.match(/(?<=\.)[\d]+$/) || [''])[0].length;
|
||||||
}(step.toString()));
|
}(step.toString());
|
||||||
|
if(fixed) value = value.toFixed(fixed);
|
||||||
|
|
||||||
elem.val(value);
|
elem.val(value);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue