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