我正在尝试将“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”属性。 …