'.slider-container'); var dataName = $sliderContainer.data('name'); // 方法1:jQuery的data() $("#"+dataName+"_max").val(self.currentMax); $("#"+dataName+"_min").val(self.currentMin); $(document).off('mousemove touchmove'); $(document).off('mouseup touchend'); self.$minThumb.add(self.$maxThumb).removeClass('active'); getLoadData('select'); }); }); } // 设置值 setValues(min, max) { this.currentMin = Math.max(this.minValue, min); this.currentMax = Math.min(this.maxValue, max); // 计算最小间隔(基于值范围而不是固定值) const minInterval = (this.maxValue - this.minValue) * 0.01; if (this.currentMax - this.currentMin < minInterval) { if (min === this.currentMin) { this.currentMax = this.currentMin + minInterval; } else { this.currentMin = this.currentMax - minInterval; } } this.updateThumbPosition(this.$minThumb, this.currentMin); this.updateThumbPosition(this.$maxThumb, this.currentMax); this.updateTrack(); this.updateValueDisplays(); } // 获取当前值 getValues() { return [this.currentMin, this.currentMax]; } }