小编Ayy*_*llu的帖子

类型“DetailedHTMLProps<LinkHTMLAttributes<HTMLLinkElement>,HTMLLinkElement>”上不存在属性“fetchPriority”

我正在尝试将“fetchPriority”添加到链接标记,如下所示。

const optionalPreload =
    ServerOnlyHead  ? (
      <ServerOnlyHead
        children={
          <link
            fetchPriority="high" // error here !!!
            rel="preload"
            as="image"
            href={image?.src || ""}
          />
        }
      />
    ) : null;
Run Code Online (Sandbox Code Playgroud)

但它会引发以下错误,

在此输入图像描述

Type '{ fetchPriority: string; rel: string; as: string; href: string; }' is not assignable to type 'DetailedHTMLProps<LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>'.
  Property 'fetchPriority' does not exist on type 'DetailedHTMLProps<LinkHTMLAttributes<HTMLLinkElement>, HTMLLinkElement>'.ts(2322)
'fetchPriority' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.ts(7022)
Run Code Online (Sandbox Code Playgroud)

我可以看到 LinkHTMLAttributes 没有“fetchPriority”属性。 …

typescript react-typescript

5
推荐指数
0
解决办法
1833
查看次数

标签 统计

react-typescript ×1

typescript ×1