Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions packages/components/slider/slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ export default class Slider extends SuperComponent {
}

triggerValue(value?: SliderValue) {
if (this.preval === value) return;
this.preval = value;
const trimmedValue = trimValue(value, this.properties);
if (JSON.stringify(this.preval) === JSON.stringify(trimmedValue)) return;
this.preval = trimmedValue;
this._trigger('change', {
value: trimValue(value, this.properties),
value: trimmedValue,
});
}

Expand Down Expand Up @@ -215,7 +216,10 @@ export default class Slider extends SuperComponent {
const value = trimValue(newValue, this.properties);
const realLabel = this.getLabelByValue(value);

this.triggerValue(value);
// 避免受控模式下死循环,同时不影响初始化后的首次点击
if (this.preval !== undefined) {
this.preval = value;
}

const setValueAndTrigger = () => {
this.setData({
Expand Down
Loading