File tree Expand file tree Collapse file tree
packages/components/slider Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -177,10 +177,11 @@ export default class Slider extends SuperComponent {
177177 }
178178
179179 triggerValue ( value ?: SliderValue ) {
180- if ( this . preval === value ) return ;
181- this . preval = value ;
180+ const trimmedValue = trimValue ( value , this . properties ) ;
181+ if ( JSON . stringify ( this . preval ) === JSON . stringify ( trimmedValue ) ) return ;
182+ this . preval = trimmedValue ;
182183 this . _trigger ( 'change' , {
183- value : trimValue ( value , this . properties ) ,
184+ value : trimmedValue ,
184185 } ) ;
185186 }
186187
@@ -215,7 +216,10 @@ export default class Slider extends SuperComponent {
215216 const value = trimValue ( newValue , this . properties ) ;
216217 const realLabel = this . getLabelByValue ( value ) ;
217218
218- this . triggerValue ( value ) ;
219+ // 避免受控模式下死循环,同时不影响初始化后的首次点击
220+ if ( this . preval !== undefined ) {
221+ this . preval = value ;
222+ }
219223
220224 const setValueAndTrigger = ( ) => {
221225 this . setData ( {
You can’t perform that action at this time.
0 commit comments