gpt4 book ai didi

typescript - 相当于 React.HTMLProps<...> 的 Solid JS

转载 作者:行者123 更新时间:2023-12-05 01:54:09 27 4
gpt4 key购买 nike

我有一个 React 组件,其 prop 类型如下:

type Props = React.HTMLProps<HTMLAnchorElement> & {
to?: string;
};

如何在 SolidJS 中编写等效的 Prop 类型?我试过这个:

type Props = Component<HTMLAnchorElement> & {
to?: string;
};

它可以编译,但它没有与前者相同的内置 Prop ,例如 children

最佳答案

Solid JS 有 JSX.IntrinsicElements,它提供由标签名称索引的属性类型:

import { JSX } from 'solid-js';

type Props = JSX.IntrinsicElements['a'] & {
to?: string;
};

关于typescript - 相当于 React.HTMLProps<...> 的 Solid JS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70810158/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com