mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(slider): empty range value (#9409)
* fix: slider empty range value * fix: update slider default range value
This commit is contained in:
parent
51b326fcdb
commit
5b8f1d9be1
@ -130,17 +130,17 @@ export default defineComponent({
|
||||
const isSameValue = (newValue: SliderValue, oldValue: SliderValue) =>
|
||||
JSON.stringify(newValue) === JSON.stringify(oldValue);
|
||||
|
||||
// 处理两个滑块重叠之后的情况
|
||||
const handleOverlap = (value: NumberRange) => {
|
||||
if (value[0] > value[1]) {
|
||||
return value.slice(0).reverse();
|
||||
}
|
||||
return value;
|
||||
const handleRangeValue = (value: NumberRange) => {
|
||||
// 设置默认值
|
||||
const left = value[0] ?? Number(props.min);
|
||||
const right = value[1] ?? Number(props.max);
|
||||
// 处理两个滑块重叠之后的情况
|
||||
return left > right ? [right, left] : [left, right];
|
||||
};
|
||||
|
||||
const updateValue = (value: SliderValue, end?: boolean) => {
|
||||
if (isRange(value)) {
|
||||
value = handleOverlap(value).map(format) as NumberRange;
|
||||
value = handleRangeValue(value).map(format) as NumberRange;
|
||||
} else {
|
||||
value = format(value);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user