🐛(component): 修复 input-number 组件经度丢失
This commit is contained in:
parent
3caf99a721
commit
aaebe4f606
@ -11,6 +11,7 @@ import { LayIcon } from "@layui/icons-vue";
|
||||
import layButton from "../button/index.vue";
|
||||
import { ref, watch, withDefaults, computed, Ref } from "vue";
|
||||
import { InputNumberSize } from "./interface";
|
||||
import { add, sub } from "./math"
|
||||
|
||||
export interface InputNumberProps {
|
||||
modelValue?: number;
|
||||
@ -84,11 +85,11 @@ const maxControl = computed(() => {
|
||||
});
|
||||
|
||||
const addition = function () {
|
||||
num.value += Number(props.step);
|
||||
num.value = add(num.value, props.step);
|
||||
};
|
||||
|
||||
const subtraction = function () {
|
||||
num.value -= Number(props.step);
|
||||
num.value = Number(sub(num.value, props.step));
|
||||
};
|
||||
|
||||
const longDown = function (fn: Function) {
|
||||
|
21
package/component/src/component/inputNumber/math.ts
Normal file
21
package/component/src/component/inputNumber/math.ts
Normal file
@ -0,0 +1,21 @@
|
||||
//加法
|
||||
function add(arg1: number, arg2: number) {
|
||||
var r1, r2, m;
|
||||
try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
|
||||
try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
|
||||
m = Math.pow(10, Math.max(r1, r2))
|
||||
return (arg1 * m + arg2 * m) / m
|
||||
}
|
||||
//减法
|
||||
function sub(arg1: number, arg2: number) {
|
||||
var r1, r2, m, n;
|
||||
try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
|
||||
try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
|
||||
m = Math.pow(10, Math.max(r1, r2));
|
||||
n = (r1 >= r2) ? r1 : r2;
|
||||
return ((arg1 * m - arg2 * m) / m).toFixed(n);
|
||||
}
|
||||
export {
|
||||
add,
|
||||
sub,
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
|
||||
<template>
|
||||
{{data1}}
|
||||
<lay-input-number v-model="data1"></lay-input-number>
|
||||
<lay-input-number v-model="data1" :step="0.1"></lay-input-number>
|
||||
<lay-input-number v-model="data2" position="right"></lay-input-number>
|
||||
</template>
|
||||
|
||||
|
@ -17,13 +17,13 @@
|
||||
<h3>1.7.6 <span class="layui-badge-rim">2022-11-07</span></h3>
|
||||
<ul>
|
||||
<li>[新增] page-header 组件 back-icon 属性, 自定义返回图标。</li>
|
||||
<li>[修复] datePicker 组件 年选择器 清空后再点击确定回显错误。</li>
|
||||
<li>[修复] select 组件 单选模式 与 多选模式 清空操作样式不统一的问题。</li>
|
||||
<li>[修复] select 组件 单选模式 与 多选模式 下拉宽度不一致的问题。</li>
|
||||
<li>[修复] select 组件 多选模式 @search 事件不生效的问题。</li>
|
||||
<li>[优化] select 组件 label 属性不兼容 number 类型。</li>
|
||||
<li>[优化] select-option 组件 label 属性为 null 时, 单选不展示。</li>
|
||||
<li>[优化] select-option 组件 label 属性为 null 时, 搜索报错。</li>
|
||||
<li>[修复] datePicker 组件 年选择器 清空后再点击确定回显错误。</li>
|
||||
<li>[优化] datePicker 组件 新增change,blur,foucs事件。</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
Loading…
Reference in New Issue
Block a user