Skip to content

Commit

Permalink
doc: update docs/typescript.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jul 11, 2023
1 parent 1e68618 commit 5f87a74
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,20 @@ export interface ProgressProps extends React.DetailedHTMLProps<React.HTMLAttribu
export const Progress: FC<PropsWithRef<ProgressProps>> = forwardRef<HTMLDivElement>(InternalProgress)
```

### 组件 'as' 属性
<!--rehype:wrap-class=col-span-3-->

```tsx
import React, { ElementType, ComponentPropsWithoutRef } from "react";

export const Link = <T extends ElementType<any> = "a">(props: { as?: T; } & ComponentPropsWithoutRef<T>) => {
const Comp = props.as || "a";
return <Comp {...props}></Comp>;
};
```

允许传入自定义 `React` 组件,或 `div`, `a` 标签

各种各样的技巧
---

Expand Down

0 comments on commit 5f87a74

Please sign in to comment.