File tree Expand file tree Collapse file tree 1 file changed +27
-14
lines changed
src/components/pivottable-ui Expand file tree Collapse file tree 1 file changed +27
-14
lines changed Original file line number Diff line number Diff line change 77 v-for =" (text, key) in options"
88 :key =" key"
99 :value =" text"
10- :selected =" text === valueModel ? 'selected' : undefined"
1110 >
1211 {{ text }}
1312 </option >
1413 </select >
1514</template >
1615
17- <script setup>
16+ <script setup lang="ts" >
1817import { ref , watch } from ' vue'
1918
20- const props = defineProps ({
21- options: {
22- type: Array ,
23- default : () => []
24- },
25- value: {
26- type: String ,
27- default: ' '
28- }
19+ const emit = defineEmits <{
20+ (event : ' update:value' , value : string ): void
21+ }>()
22+
23+ interface DropdownProps {
24+ options: string []
25+ value: string
26+ }
27+
28+ const props = withDefaults (defineProps <DropdownProps >(), {
29+ options : () => [],
30+ value: ' '
2931})
30- const valueModel = ref (props .value || props .options [0 ])
31- const emit = defineEmits ([' update:value' ])
32+
33+ const valueModel = ref <string >(' ' )
34+
35+ watch (
36+ [() => props .value , () => props .options ],
37+ ([val , opts ]: [string , string []]) => {
38+ valueModel .value = val || opts [0 ] || ' '
39+ },
40+ { immediate: true }
41+ )
42+
3243watch (
3344 valueModel ,
34- (newVal ) => { emit (' update:value' , newVal) },
45+ (newVal ) => {
46+ emit (' update:value' , newVal )
47+ },
3548 { immediate: true }
3649)
3750 </script >
You can’t perform that action at this time.
0 commit comments