From 5f87a747205cb5c951263577ae8e40b60ce9ea8f Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Tue, 11 Jul 2023 23:54:21 +0800 Subject: [PATCH] doc: update docs/typescript.md --- docs/typescript.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/typescript.md b/docs/typescript.md index 23718f2..f8bed22 100644 --- a/docs/typescript.md +++ b/docs/typescript.md @@ -1289,6 +1289,20 @@ export interface ProgressProps extends React.DetailedHTMLProps> = forwardRef(InternalProgress) ``` +### 组件 'as' 属性 + + +```tsx +import React, { ElementType, ComponentPropsWithoutRef } from "react"; + +export const Link = = "a">(props: { as?: T; } & ComponentPropsWithoutRef) => { + const Comp = props.as || "a"; + return ; +}; +``` + +允许传入自定义 `React` 组件,或 `div`, `a` 标签 + 各种各样的技巧 ---