mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-05 16:17:00 +08:00
init
This commit is contained in:
30
admin/src/components/dict-value/index.vue
Normal file
30
admin/src/components/dict-value/index.vue
Normal file
@@ -0,0 +1,30 @@
|
||||
<template>
|
||||
<div>
|
||||
<template v-for="(item, index) in getOptions" :key="index">
|
||||
<span>{{ index != 0 ? '、' : '' }}{{ item.name }}</span>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
options: any[]
|
||||
value: any
|
||||
}>(),
|
||||
{
|
||||
options: () => []
|
||||
}
|
||||
)
|
||||
|
||||
const values = computed(() => {
|
||||
if (props.value !== null && typeof props.value !== 'undefined') {
|
||||
return Array.isArray(props.value) ? props.value : String(props.value).split(',')
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
})
|
||||
|
||||
const getOptions = computed(() => {
|
||||
return props.options.filter((item) => values.value.includes(item.value))
|
||||
})
|
||||
</script>
|
Reference in New Issue
Block a user