naive-ui的n-input举例
<template>
<n-input
clearable
placeholder=""
v-bind="$attrs"
>
<template v-for="(value, name) in $slots" #[name] = "slotData">
<slot :name="name" v-bind="slotData || {}"></slot>
</template>
</n-input>
</template>
//import { useAttrs, useSlots } from 'vue'
//const slots = useSlots()
//const attrs = useAttrs()
<script lang='ts' setup>
</script>
<style scoped lang='less'>
</style>
标签:封装,useAttrs,useSlots,Vue3,组件,const
From: https://www.cnblogs.com/DaiTouE/p/17579887.html