huangyinfeng
6 天以前 a9a03d64cf190188d3db04d14970fc0908b03491
src/components/ColorPicker/index.vue
@@ -28,6 +28,7 @@
              button-style="solid"
              size="small"
              name="color"
              @change="groupChange"
            >
              <a-radio-button
                v-for="item in colors"
@@ -55,7 +56,7 @@
  const props = defineProps({
    modelValue: {
      type: String,
      default:'#000000',
      default: '#000000',
      required: true,
    },
    // 1普通,2选择器模式
@@ -67,7 +68,7 @@
  });
  // 定义 emits,用于双向绑定
  const emit = defineEmits(['update:modelValue','change']);
  const emit = defineEmits(['update:modelValue', 'change']);
  // 颜色选项
  const colors = ref([
@@ -105,8 +106,13 @@
  // 当本地值发生变化时,发出 update:modelValue 事件,通知父组件更新
  watch(localValue, (newValue) => {
    emit('update:modelValue', newValue);
    emit('change', newValue);
    // emit('change', newValue);
  });
  function groupChange() {
    console.log(localValue.value, '------------2');
    emit('change', localValue.value);
  }
</script>
<style lang="less" scoped>
@@ -155,6 +161,5 @@
    height: 8px;
    background-color: #fff;
    clip-path: polygon(50% 60%, 0% 100%, 100% 100%); /* Triangle at the bottom */
  }
</style>