fix: 修复一些问题

This commit is contained in:
dap 2024-09-23 17:56:55 +08:00
parent 3e750a0943
commit dcebda7ca6

View File

@ -10,6 +10,13 @@ import {
import { tagSelectOptions } from '#/components/dict';
/**
* 需要禁止透传
* 不禁止会有奇怪的bug 会绑定到selectType上
* TODO: 未知原因 有待研究
*/
defineOptions({ inheritAttrs: false });
defineEmits<{ deselect: [] }>();
const options = [
@ -31,21 +38,22 @@ const selectType = defineModel('selectType', {
type: String as PropType<SelectType>,
});
/**
* color必须为hex颜色或者undefined
*/
const color = defineModel('value', {
default: '',
type: String,
default: undefined,
type: String as PropType<string | undefined>,
});
function handleSelectTypeChange(e: RadioChangeEvent) {
// hex
if (e.target.value === 'custom') {
color.value = '#FFFFFF';
}
// hex
color.value = e.target.value === 'custom' ? '#000000' : undefined;
}
</script>
<template>
<div class="flex items-center gap-[6px]">
<div class="flex flex-1 items-center gap-[6px]">
<RadioGroup
v-model:value="selectType"
:options="computedOptions"
@ -55,6 +63,7 @@ function handleSelectTypeChange(e: RadioChangeEvent) {
/>
<Select
v-if="selectType === 'default'"
v-model:value="color"
:allow-clear="true"
:options="tagSelectOptions()"
class="flex-1"