mirror of
https://github.com/motajs/template.git
synced 2026-11-22 04:54:30 +08:00
fix: slider 的 clamp 问题
This commit is contained in:
1 parent
6c7ed43fbc
commit
51a2a66847
1 file changed
+4
-3
@@ -166,9 +166,10 @@ export const Slider = defineComponent<
|
||||
const targetValue = ratio * (max.value - min.value) + min.value;
|
||||
const step = props.step ?? 1;
|
||||
const steps = Math.round((targetValue - min.value) / step);
|
||||
const aligned = steps * step + min.value;
|
||||
value.value = clamp(aligned, min.value, max.value);
|
||||
emit('update:value', aligned);
|
||||
const aligned = Number((steps * step + min.value).toFixed(8));
|
||||
const clamped = clamp(aligned, min.value, max.value);
|
||||
value.value = clamped;
|
||||
emit('update:value', clamped);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user