From cd07742407fb30c443a23c4158ddad4e8d4505d9 Mon Sep 17 00:00:00 2001 From: bin.yang Date: Mon, 2 Apr 2018 11:24:43 +0800 Subject: [PATCH] slider组件 step为小数时回不到100的bug --- src/components/slider/slider.vue | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/slider/slider.vue b/src/components/slider/slider.vue index 891823c..ec91eeb 100644 --- a/src/components/slider/slider.vue +++ b/src/components/slider/slider.vue @@ -327,7 +327,7 @@ if (type === 'min') newPos = this.checkLimits([newPos, this.maxPosition])[0]; else newPos = this.checkLimits([this.minPosition, newPos])[1]; - const modulus = this.handleDecimal(newPos,this.step) + const modulus = this.handleDecimal(newPos,this.step); const value = this.currentValue; value[index] = newPos - modulus; this.currentValue = [...value]; @@ -342,10 +342,12 @@ if(step<1){ let sl = step.toString(), multiple = 1, - m = 0; + m; try { - m += sl.split('.')[1].length; - } catch (e) {} + m = sl.split('.')[1].length; + } catch (e){ + m = 0; + } multiple = Math.pow(10,m); return (pos * multiple) % (step * multiple) / multiple; }else return pos % step; -- libgit2 0.21.4