我创建了一个样式化的组件
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;
`;
编辑:要回答我自己的问题,看起来我必须在Text组件上进行,并且无法在我的样式组件上创建样式组件。
使用text-decoration
而不是textDecoration
。
使用text-decoration: line-through;
您也可以使用text-decoration-color: red
设置线条样式
您使用的是样式化组件,因此使用text-decoration
而不是textDecoration
,并使用句点而不是方括号:
const StrikeThrough = styled.Text`
text-decoration: line-through;
`;