|
28 | 28 | </div> |
29 | 29 | </template> |
30 | 30 | <script setup lang="ts"> |
31 | | -import { defineProps, defineEmits, computed, useSlots, ref } from 'vue'; |
| 31 | +import { defineProps, defineEmits, computed, useSlots, ref, watch } from 'vue'; |
32 | 32 | import { FTag, FSelect } from '@fesjs/fes-design'; |
33 | 33 | import { useLocale } from '../hooks/useLocale'; |
34 | 34 |
|
@@ -81,14 +81,15 @@ const deleteTag = (item: any, index: number) => { |
81 | 81 | const cacheOptions = ref<any[]>([]); |
82 | 82 | const isSlotHeader = computed(() => !!useSlots().header); |
83 | 83 | const handleChange = (val: any) => { |
84 | | - cacheOptions.value.push(...props.options); |
| 84 | + emit('selectorChange', val); |
| 85 | +}; |
| 86 | +watch(() => props.options, (oldVal, newVal) => { |
| 87 | + cacheOptions.value.push(...(props.options as any[])); |
| 88 | + // 基于value去重,保证cacheOptions能保证最小 |
85 | 89 | cacheOptions.value = cacheOptions.value.filter((item, index, self) => { |
86 | 90 | return self.findIndex(el => el.value === item.value) === index; |
87 | 91 | }); |
88 | | - cacheOptions.value = cacheOptions.value.filter(item => val.includes(item.value)); |
89 | | - emit('selectorChange', val); |
90 | | -}; |
91 | | -
|
| 92 | +}, { immediate: true }); |
92 | 93 | const handleClear = () => { |
93 | 94 | selectedList.value = []; |
94 | 95 | emit('clearAll'); |
|
0 commit comments