在 React 和 TypeScript 中扩展 HTML <a> 标签元素

yun*_*ver 6 javascript typescript reactjs htmlelements

我在 React 项目中使用打字稿,我想添加标签的道具。我可以访问元素的属性link,但不能访问属性a元素。link当标签的属性使用标签时,我收到错误a

React 中的元素是否有“HTMLAElement”结构a

const MyComponent: FunctionComponent<React.LinkHTMLAttributes<HTMLLinkElement>> = (
props: React.LinkHTMLAttributes<HTMLLinkElement>,
) => {
  return (
      <a {...props} className="mycomponent">  // When I use it with the <link> it doesn't give an error but I need <a>.
         MyComponent
      </a>
  );
};
Run Code Online (Sandbox Code Playgroud)

yun*_*ver 10

我的问题解决了。当我使用“HTMLAnchorElement”时,错误消失了。我不知道元素“a”对应于“anchor”。