File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed
docs/document-component/src/document/zh-CN/components
packages/component/src/component/inputNumber Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 136
136
137
137
:::
138
138
139
- ::: title 精度
139
+ ::: title 精度与后缀
140
140
:::
141
141
142
- ::: demo ` precision ` 设置 precision 属性可以控制数值精度,接收一个 Number。
142
+ ::: demo ` precision ` 设置 precision 属性可以控制数值精度,接收一个 Number。可以同时使用 ` indicator ` 设置一个后缀。
143
143
144
144
<template >
145
145
<lay-input-number v-model =" data12 " :precision =" 2 " :step =" 0.1 " :max =" 10 " ></lay-input-number >
146
+ <lay-input-number v-model =" data12 " :precision =" 2 " :step =" 0.1 " :max =" 10 " indicator =" % " ></lay-input-number >
147
+ <lay-input-number v-model =" data12 " :precision =" 2 " :step =" 0.1 " :max =" 10 " indicator =" 时 " position =" right " ></lay-input-number >
146
148
</template >
147
149
148
150
<script >
208
210
| min | 最小可输入的数 | ` number ` | -- |
209
211
| max | 最大可输入的数 | ` number ` | -- |
210
212
| size | 尺寸, 可选值` md ` / ` sm ` / ` xs ` | ` string ` | 默认为最大尺寸 |
213
+ | indicator | 后缀标识 | ` string ` | -- |
211
214
212
215
:::
213
216
Original file line number Diff line number Diff line change 22
22
height : @size ;
23
23
width : @width ;
24
24
25
+ .layui-input-number-indicator {
26
+ pointer-events : none ;
27
+ position : absolute ;
28
+ height : 100% ;
29
+ top : 0 ;
30
+ line-height : @size ;
31
+ text-align : center ;
32
+ background-color : #fff ;
33
+ width : @width ;
34
+ overflow : hidden ;
35
+ }
36
+
25
37
.layui-input {
26
38
height : @size ;
27
39
line-height : @size ;
45
57
line-height : @right-size ;
46
58
}
47
59
60
+ .layui-input-number-indicator {
61
+ left : 0 ;
62
+ width : calc (@width - @right-size - calc (@size / 2 ));
63
+ }
64
+
48
65
.layui-subtraction-btn {
49
66
top : @right-size - 1 ;
50
67
}
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ export interface InputNumberProps {
21
21
position? : " right" ;
22
22
min? : number ;
23
23
max? : number ;
24
+ indicator? : string ;
24
25
}
25
26
26
27
defineOptions ({
@@ -35,9 +36,11 @@ const props = withDefaults(defineProps<InputNumberProps>(), {
35
36
stepStrictly: false ,
36
37
min: - Infinity ,
37
38
max: Infinity ,
39
+ indicator: " " ,
38
40
});
39
41
40
42
const { size } = useProps (props );
43
+ const isBlur = ref (true );
41
44
42
45
const emit = defineEmits ([
43
46
" update:modelValue" ,
@@ -201,10 +204,12 @@ const onChange = (value: string) => {
201
204
202
205
const onBlur = (event : FocusEvent ) => {
203
206
emit (" blur" , event );
207
+ isBlur .value = true ;
204
208
};
205
209
206
210
const onFocus = (event : FocusEvent ) => {
207
211
emit (" focus" , event );
212
+ isBlur .value = false ;
208
213
};
209
214
210
215
const addition = () => {
@@ -262,6 +267,7 @@ const maxDisabled = computed(() => {
262
267
</lay-button >
263
268
<div class =" layui-input-number-input" >
264
269
<lay-input
270
+ :title =" `${inputValue}${indicator}`"
265
271
:max =" max"
266
272
:min =" min"
267
273
:name =" name"
@@ -274,6 +280,12 @@ const maxDisabled = computed(() => {
274
280
@focus =" onFocus"
275
281
type =" number"
276
282
/>
283
+ <div
284
+ class =" layui-input-number-indicator"
285
+ v-if =" isBlur && !!indicator"
286
+ >
287
+ {{ `${inputValue}${indicator}` }}
288
+ </div >
277
289
</div >
278
290
<lay-button
279
291
size =" lg"
You can’t perform that action at this time.
0 commit comments