File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ Component({
2424 type : Number ,
2525 value : 1
2626 } ,
27+ roundFloat : {
28+ type : Boolean ,
29+ value : false
30+ } ,
2731 disabled : Boolean ,
2832 iconSize : String ,
2933 iconColor : String
@@ -62,6 +66,7 @@ Component({
6266 let {
6367 value
6468 } = e . detail ;
69+ // setTimeout留出修改count的时间,保证调整一些不合适的数值
6570 setTimeout ( ( ) => {
6671 this . blurCount ( Number ( value ) , ( ) => {
6772 eventUtil . emit ( this , 'lintap' , { count : this . data . count , type : 'blur' } ) ;
@@ -91,6 +96,10 @@ Component({
9196 value = value > max ? max : value ;
9297 value = value < min ? min : value ;
9398
99+ // 4舍5入
100+ if ( this . data . roundFloat ) {
101+ value = Math . round ( value ) ;
102+ }
94103 // 更新页面显示数值
95104 value === this . data . count && this . setData ( { focus : false } ) ;
96105 value !== this . data . count && this . setData ( { count : value } , ( ) => {
You can’t perform that action at this time.
0 commit comments