Преглед на файлове

ColorPicker: replace watch hue with computed

kingwl преди 8 години
родител
ревизия
cc7a461db5
променени са 2 файла, в които са добавени 14 реда и са изтрити 3 реда
  1. 8 1
      packages/color-picker/src/components/hue-slider.vue
  2. 6 2
      packages/color-picker/src/components/sv-panel.vue

+ 8 - 1
packages/color-picker/src/components/hue-slider.vue

@@ -32,8 +32,15 @@
       };
     },
 
+    computed: {
+      hueValue() {
+        const hue = this.color.get('hue');
+        return hue;
+      }
+    },
+
     watch: {
-      'color._hue'() {
+      hueValue() {
         this.update();
       }
     },

+ 6 - 2
packages/color-picker/src/components/sv-panel.vue

@@ -28,15 +28,19 @@
     },
 
     computed: {
-      // while watch hue and value with computed to call update once
       colorValue() {
         const hue = this.color.get('hue');
         const value = this.color.get('value');
-        this.update();
         return { hue, value };
       }
     },
 
+    watch: {
+      colorValue() {
+        this.update();
+      }
+    },
+
     methods: {
       update() {
         const saturation = this.color.get('saturation');