Lzh on GitHub

useForwardProps

转发组件的 props,不进行布尔类型转换。

当您为组件构建包装器时,在某些情况下,您可能希望忽略 Vue 的 Props 布尔类型转换

您可以将所有布尔字段的默认值设置为 undefined,或者使用此组合式函数。

它的核心目标是:帮助你在组件中“透传” props,即:合并和保留外部传入的 props,并将它们正确应用到你的组件上。

用法

<script setup lang="ts">
import { useForwardProps } from 'reka-ui'

const props = defineProps<CompEmitProps>()
const forwarded = useForwardProps(props)
</script>

<template>
  <Comp v-bind="forwarded">
    ...
  </Comp>
</template>