精简优化number组件

master
yutent 2023-11-29 13:42:07 +08:00
parent eba5090656
commit 7654fc8da7
1 changed files with 17 additions and 35 deletions

View File

@ -106,39 +106,13 @@ class InputNumber extends Component {
`,
// 尺寸
css`
@use 'sass:map';
$sizes: (
s: (
w: 52px,
h: 20px,
f: 12px
),
m: (
w: 72px,
h: 24px,
f: 12px
),
xl: (
w: 132px,
h: 36px,
f: 14px
),
xxl: (
w: 160px,
h: 44px,
f: 16px
)
);
:host([size='small']) {
min-width: 72px;
height: 24px;
font-size: 12px;
@loop $s, $v in $sizes {
:host([size='#{$s}']) {
min-width: map.get($v, 'w');
height: map.get($v, 'h');
font-size: map.get($v, 'f');
button {
width: map.get($v, 'h') + 2;
}
button {
width: 26px;
}
}
@ -160,9 +134,7 @@ class InputNumber extends Component {
info: 'blue',
success: 'green',
warning: 'orange',
danger: 'red',
secondary: 'dark',
help: 'grey'
danger: 'red'
);
@loop $t, $c in $colors {
@ -225,7 +197,17 @@ class InputNumber extends Component {
}
#fetch(value) {
let now = Date.now()
let { lazy } = this
this.value = value
// 并发拦截
if (lazy && now - this.#stamp < lazy) {
return
}
this.#stamp = now
this.$emit('input')
this.$emit('change')
}