element-plus/docs/.vitepress/vitepress/components/globals/vp-api-function.vue
Jeremy dd65c73870
docs(components): [affix] (#10345)
docs(components): [affix]

* Add lost exposed API to documentation.
* Refine code.
* Add descriptions for APIs.
* Refine implementation for `FunctionType` and `EnumType`.
* Update affix documentation based on the changes above.

Co-authored-by: JeremyWuuuuu <15975785+JeremyWuuuuu@users.noreply.github.com>
2022-11-01 21:52:16 +08:00

38 lines
776 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]) => params.concat([`${key}: ${val}`]),
[] as string[]
)
.join(', ')
)
const details = computed(() => `(${mappedParams.value}) => ${props.returns}`)
</script>
<template>
<api-typing type="Function" :details="details" />
</template>