Browse Source

Rate: Fix decimal display support in disabled mode (#15089)

Haoran Yu 6 years ago
parent
commit
f19b9f13c6
2 changed files with 3 additions and 4 deletions
  1. 2 3
      packages/rate/src/main.vue
  2. 1 1
      test/unit/specs/rate.spec.js

+ 2 - 3
packages/rate/src/main.vue

@@ -148,9 +148,8 @@
       decimalStyle() {
       decimalStyle() {
         let width = '';
         let width = '';
         if (this.rateDisabled) {
         if (this.rateDisabled) {
-          width = `${ this.valueDecimal < 50 ? 0 : 50 }%`;
-        }
-        if (this.allowHalf) {
+          width = `${ this.valueDecimal }%`;
+        } else if (this.allowHalf) {
           width = '50%';
           width = '50%';
         }
         }
         return {
         return {

+ 1 - 1
test/unit/specs/rate.spec.js

@@ -181,7 +181,7 @@ describe('Rate', () => {
 
 
     const fourthStar = vm2.$el.querySelectorAll('.el-rate__item')[3];
     const fourthStar = vm2.$el.querySelectorAll('.el-rate__item')[3];
     const halfStar = fourthStar.querySelector('.el-rate__decimal');
     const halfStar = fourthStar.querySelector('.el-rate__decimal');
-    expect(halfStar.style.width).to.equal('0%');
+    expect(halfStar.style.width).to.equal('40%');
   });
   });
 
 
   it('allow half', () => {
   it('allow half', () => {