使用样式组件,如何从DIV组件中继承所有Prop并将其转换为输入?
在这种情况下, 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
多态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