mirror of https://github.com/layui/layui
commit
3464fb3e17
|
@ -121,7 +121,7 @@ toc: true
|
|||
| step | 设置数字的加减间隔 |
|
||||
| min | 设置数字的最小值 |
|
||||
| max | 设置数字的最大值 |
|
||||
| lay-precision <sup>2.8.18+</sup> | 设置数字的小数位精度 |
|
||||
| lay-precision <sup>2.8.18+</sup> | 设置数字的小数位精度。注<sup>2.9.8+</sup>:若值为 `0`,则表示取整。 |
|
||||
|
||||
### 示例
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md3">
|
||||
<input type="number" value="1.1" name="arr[]" required placeholder="数字输入框" lay-affix="number" autocomplete="off" class="layui-input">
|
||||
<input type="number" value="1.1" lay-precision="0" name="arr[]" required placeholder="数字输入框" lay-affix="number" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-col-md3">
|
||||
<input type="number" step="0.01" min="0" max="10" name="arr[]" required placeholder="数字输入框" lay-affix="number" autocomplete="off" class="layui-input">
|
||||
|
|
|
@ -201,13 +201,19 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
|||
|
||||
precision = precision >= 0 ? precision : Math.max(decimals(step), decimals(rawValue));
|
||||
|
||||
if(!noAction){
|
||||
// 赋值
|
||||
if (!noAction) {
|
||||
// 初始渲染时只处理数字精度
|
||||
if(!isInit){
|
||||
if (!isInit) {
|
||||
if(value <= min) value = min;
|
||||
if(value >= max) value = max;
|
||||
}
|
||||
if(precision) value = value.toFixed(precision);
|
||||
// 若 `lay-precision` 为 0, 则表示只保留整数
|
||||
if (precision === 0) {
|
||||
value = parseInt(value);
|
||||
} else if(precision > 0) { // 小数位精度
|
||||
value = value.toFixed(precision);
|
||||
}
|
||||
elem.val(value);
|
||||
}
|
||||
|
||||
|
|
|
@ -510,7 +510,7 @@ layui.define(['lay', 'layer'], function(exports){
|
|||
break;
|
||||
default: // 图片文件
|
||||
layui.each(value, function(i, item){
|
||||
if(!RegExp('.\\.('+ (exts || 'jpg|png|gif|bmp|jpeg|svg') +')$', 'i').test(escape(item))){
|
||||
if(!RegExp('.\\.('+ (exts || 'jpg|png|gif|bmp|jpeg|svg|webp') +')$', 'i').test(escape(item))){
|
||||
return check = true;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue