升级uni-ui到最新版本1.5.7

This commit is contained in:
RuoYi
2025-03-25 16:58:54 +08:00
parent dae8945a43
commit 315832d151
127 changed files with 7327 additions and 5066 deletions

View File

@@ -1,12 +1,14 @@
<template>
<view class="uni-numbox">
<view @click="_calcValue('minus')" class="uni-numbox__minus uni-numbox-btns" :style="{background}">
<text class="uni-numbox--text" :class="{ 'uni-numbox--disabled': inputValue <= min || disabled }" :style="{color}">-</text>
<text class="uni-numbox--text" :class="{ 'uni-numbox--disabled': inputValue <= min || disabled }"
:style="{color}">-</text>
</view>
<input :disabled="disabled" @focus="_onFocus" @blur="_onBlur" class="uni-numbox__value" type="number"
v-model="inputValue" :style="{background, color}" />
<input :disabled="disabled" @focus="_onFocus" @blur="_onBlur" class="uni-numbox__value"
:type="step<1?'digit':'number'" v-model="inputValue" :style="{background, color, width:widthWithPx}" />
<view @click="_calcValue('plus')" class="uni-numbox__plus uni-numbox-btns" :style="{background}">
<text class="uni-numbox--text" :class="{ 'uni-numbox--disabled': inputValue >= max || disabled }" :style="{color}">+</text>
<text class="uni-numbox--text" :class="{ 'uni-numbox--disabled': inputValue >= max || disabled }"
:style="{color}">+</text>
</view>
</view>
</template>
@@ -21,6 +23,7 @@
* @property {Number} step 每次点击改变的间隔大小
* @property {String} background 背景色
* @property {String} color 字体颜色(前景色)
* @property {Number} width 输入框宽度(单位:px)
* @property {Boolean} disabled = [true|false] 是否为禁用状态
* @event {Function} change 输入框值改变时触发的事件,参数为输入框当前的 value
* @event {Function} focus 输入框聚焦时触发的事件,参数为 event 对象
@@ -62,6 +65,10 @@
disabled: {
type: Boolean,
default: false
},
width: {
type: Number,
default: 40,
}
},
data() {
@@ -77,6 +84,11 @@
this.inputValue = +val;
}
},
computed: {
widthWithPx() {
return this.width + 'px';
}
},
created() {
if (this.value === 1) {
this.inputValue = +this.modelValue;
@@ -114,11 +126,11 @@
}
this.inputValue = (value / scale).toFixed(String(scale).length - 1);
this.$emit("change", +this.inputValue);
// TODO vue2 兼容
this.$emit("input", +this.inputValue);
// TODO vue3 兼容
this.$emit("update:modelValue", +this.inputValue);
this.$emit("change", +this.inputValue);
},
_getDecimalScale() {
@@ -133,7 +145,7 @@
this.$emit('blur', event)
let value = event.detail.value;
if (isNaN(value)) {
this.inputValue = this.min;
this.inputValue = this.value;
return;
}
value = +value;
@@ -144,9 +156,9 @@
}
const scale = this._getDecimalScale();
this.inputValue = value.toFixed(String(scale).length - 1);
this.$emit("change", +this.inputValue);
this.$emit("input", +this.inputValue);
this.$emit("update:modelValue", +this.inputValue);
this.$emit("change", +this.inputValue);
},
_onFocus(event) {
this.$emit('focus', event)
@@ -154,7 +166,7 @@
}
};
</script>
<style lang="scss" >
<style lang="scss">
$box-height: 26px;
$bg: #f5f5f5;
$br: 2px;
@@ -188,8 +200,7 @@
height: $box-height;
text-align: center;
font-size: 14px;
border-left-width: 0;
border-right-width: 0;
border-width: 0;
color: $color;
}
@@ -206,7 +217,7 @@
.uni-numbox--text {
// fix nvue
line-height: 20px;
margin-bottom: 2px;
font-size: 20px;
font-weight: 300;
color: $color;