bianjiang преди 1 година
родител
ревизия
c9c4a55213
променени са 1 файла, в които са добавени 9 реда и са изтрити 3 реда
  1. 9 3
      src/modules/editor/components/CompUI/formItems/NewColorPicker/index.tsx

+ 9 - 3
src/modules/editor/components/CompUI/formItems/NewColorPicker/index.tsx

@@ -1,7 +1,7 @@
 import { IconPalette } from "@/assets/icons";
 import { css } from "@linaria/core";
 import { Popover } from "ant-design-vue";
-import { defineComponent, reactive } from "vue";
+import { defineComponent, reactive, watch } from "vue";
 import { any, bool } from "vue-types";
 import ColorLib from "./ColorLib";
 import { formatColor, gradientColorType } from "./ColorList";
@@ -21,13 +21,19 @@ export default defineComponent({
     const state = reactive({
       color: color || "#ffffff",
     });
-
+    watch(
+      () => props.value,
+      () => {
+        const color = getColor();
+        state.color = color;
+      }
+    );
     function getColor() {
       if (typeof props.value == "string") {
         const colorObj = Color(props.value);
         return colorObj.hex();
       } else {
-        return props.value;
+        return props.value || "#ffffff";
       }
     }