mirror of
https://github.com/element-plus/element-plus.git
synced 2024-12-21 02:50:11 +08:00
d3329cc578
* Fix crowdin possible error when using with html tag Co-authored-by: JeremyWuuuuu <15975785+JeremyWuuuuu@users.noreply.github.com>
41 lines
872 B
Vue
41 lines
872 B
Vue
<script setup lang="ts">
|
|
import { computed } from 'vue'
|
|
import ApiTyping from './vp-api-typing.vue'
|
|
|
|
import type { PropType } from 'vue'
|
|
|
|
type ParamType = [string, string]
|
|
|
|
const props = defineProps({
|
|
/**
|
|
* @description params list, shape of Array<[key: string, value: string]>
|
|
*/
|
|
params: {
|
|
type: Array as PropType<Array<ParamType>>,
|
|
default: () => [],
|
|
},
|
|
returns: {
|
|
type: String,
|
|
default: 'void',
|
|
},
|
|
})
|
|
|
|
const mappedParams = computed(() =>
|
|
props.params
|
|
.reduce((params, [key, val]) => {
|
|
let type = val
|
|
if (Array.isArray(val)) {
|
|
type = val.join(' | ')
|
|
}
|
|
return params.concat([`${key}: ${type}`])
|
|
}, [] as string[])
|
|
.join(', ')
|
|
)
|
|
|
|
const details = computed(() => `(${mappedParams.value}) => ${props.returns}`)
|
|
</script>
|
|
|
|
<template>
|
|
<api-typing type="Function" :details="details" />
|
|
</template>
|