我创建了一个样式化的组件
const StrikeThrough = styled(StandardText)`
textDecoration: line-through;
`;并将其命名为子元素,类似于<StrikeThrough>Write text here</StrikeThrough>,但呈现的文本没有这个装饰。为什么会这样?
编辑:我尝试过的其他不起作用的事情
const StrikeThrough = styled(StandardText)`
textDecorationLine: line-through;
textDecorationStyle: solid;
`;const StrikeThrough = styled(StandardText)`
text-decoration: line-through;
`;编辑:回答我自己的问题,看起来我必须在文本组件上这样做,而不能在我的样式组件之上创建一个样式化的组件。
发布于 2021-01-05 06:28:09
使用text-decoration而不是textDecoration。
发布于 2021-01-06 18:51:52
您使用的是样式组件,所以使用text-decoration代替textDecoration,使用点代替括号:
const StrikeThrough = styled.Text`
text-decoration: line-through;
`;发布于 2021-09-02 14:53:07
使用text-decoration: line-through;
您还可以使用text-decoration-color: red对行进行样式化。
https://stackoverflow.com/questions/65573776
复制相似问题