使用样式组件,如何从DIV组件中继承所有Prop并将其转换为输入?

发布于 2025-01-25 07:24:59 字数 174 浏览 1 评论 0原文

在这种情况下, box div ,我想将其转换为输入类型。

const Input = styled(Box) as styled.input`max-width: 4rem`;

In this case Box is a div and I want to convert it to input type.

const Input = styled(Box) as styled.input`max-width: 4rem`;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

守护在此方 2025-02-01 07:24:59

您可以使用多态Prop简单地构成样式组件。
有关更多信息,请尝试以下链接: https://styled-components.com/docs.com/docs.com/docs /API#AS-POLYORMORPOR-PROP

You can simply polymorph the styled component using polymorphic prop.
For more informations try this link: https://styled-components.com/docs/api#as-polymorphic-prop

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文