guregu/null测试失败版

This commit is contained in:
xiangheng
2024-08-09 14:01:05 +08:00
parent f0fe3f493f
commit cae4690703
35 changed files with 790 additions and 370 deletions

View File

@@ -1,7 +1,9 @@
<template>
<div>
<template v-for="(item, index) in getOptions" :key="index">
<span :style="{ color: item.color }">{{ index != 0 ? '、' : '' }}{{ item.name }}</span>
<span :style="{ color: item.color }"
>{{ index != 0 ? '、' : '' }}{{ item[props.valueKey] }}</span
>
</template>
</div>
</template>
@@ -10,9 +12,14 @@ const props = withDefaults(
defineProps<{
options: any[]
value: any
labelKey?: string
valueKey?: string
}>(),
{
options: () => []
options: () => [],
value: null,
labelKey: 'name',
valueKey: 'value'
}
)
@@ -25,6 +32,6 @@ const values = computed(() => {
})
const getOptions = computed(() => {
return props.options.filter((item) => values.value.includes(item.value))
return props.options.filter((item) => values.value.includes(item[props.valueKey]))
})
</script>