File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ Component({
24
24
type : Number ,
25
25
value : 1
26
26
} ,
27
+ roundFloat : {
28
+ type : Boolean ,
29
+ value : false
30
+ } ,
27
31
disabled : Boolean ,
28
32
iconSize : String ,
29
33
iconColor : String
@@ -62,6 +66,7 @@ Component({
62
66
let {
63
67
value
64
68
} = e . detail ;
69
+ // setTimeout留出修改count的时间,保证调整一些不合适的数值
65
70
setTimeout ( ( ) => {
66
71
this . blurCount ( Number ( value ) , ( ) => {
67
72
eventUtil . emit ( this , 'lintap' , { count : this . data . count , type : 'blur' } ) ;
@@ -91,6 +96,10 @@ Component({
91
96
value = value > max ? max : value ;
92
97
value = value < min ? min : value ;
93
98
99
+ // 4舍5入
100
+ if ( this . data . roundFloat ) {
101
+ value = Math . round ( value ) ;
102
+ }
94
103
// 更新页面显示数值
95
104
value === this . data . count && this . setData ( { focus : false } ) ;
96
105
value !== this . data . count && this . setData ( { count : value } , ( ) => {
You can’t perform that action at this time.
0 commit comments