🐛(component): 修复 input-number 组件经度丢失

This commit is contained in:
就眠儀式 2022-11-08 23:09:56 +08:00
parent 3caf99a721
commit aaebe4f606
4 changed files with 26 additions and 4 deletions

View File

@ -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) {

View 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,
}

View File

@ -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>

View File

@ -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>