Commit cd07742407fb30c443a23c4158ddad4e8d4505d9
1 parent
3b71312a
slider组件 step为小数时回不到100的bug
Showing
1 changed file
with
6 additions
and
4 deletions
Show diff stats
src/components/slider/slider.vue
@@ -327,7 +327,7 @@ | @@ -327,7 +327,7 @@ | ||
327 | if (type === 'min') newPos = this.checkLimits([newPos, this.maxPosition])[0]; | 327 | if (type === 'min') newPos = this.checkLimits([newPos, this.maxPosition])[0]; |
328 | else newPos = this.checkLimits([this.minPosition, newPos])[1]; | 328 | else newPos = this.checkLimits([this.minPosition, newPos])[1]; |
329 | 329 | ||
330 | - const modulus = this.handleDecimal(newPos,this.step) | 330 | + const modulus = this.handleDecimal(newPos,this.step); |
331 | const value = this.currentValue; | 331 | const value = this.currentValue; |
332 | value[index] = newPos - modulus; | 332 | value[index] = newPos - modulus; |
333 | this.currentValue = [...value]; | 333 | this.currentValue = [...value]; |
@@ -342,10 +342,12 @@ | @@ -342,10 +342,12 @@ | ||
342 | if(step<1){ | 342 | if(step<1){ |
343 | let sl = step.toString(), | 343 | let sl = step.toString(), |
344 | multiple = 1, | 344 | multiple = 1, |
345 | - m = 0; | 345 | + m; |
346 | try { | 346 | try { |
347 | - m += sl.split('.')[1].length; | ||
348 | - } catch (e) {} | 347 | + m = sl.split('.')[1].length; |
348 | + } catch (e){ | ||
349 | + m = 0; | ||
350 | + } | ||
349 | multiple = Math.pow(10,m); | 351 | multiple = Math.pow(10,m); |
350 | return (pos * multiple) % (step * multiple) / multiple; | 352 | return (pos * multiple) % (step * multiple) / multiple; |
351 | }else return pos % step; | 353 | }else return pos % step; |