如何通过Text in react native添加删除?

Mad*_*hur 18 css android reactjs react-native

嘿我想以10美元的金额添加Strike Through以显示削减金额.请检查以下内容:

<View style={styles.row}>
    <View style={styles.inputWrapstotal}>
        <Text style={styles.labelcolor}>16.7% Off</Text>
    </View>
    <View style={styles.inputWrapstotal}>
        <Text style={styles.labelamount}>Rs $10</Text>
        <Text style={styles.labelamountchange}> 12 </Text>
    </View>
</View>
Run Code Online (Sandbox Code Playgroud)

请添加css,以便我可以在两行文本中对齐,在此先感谢.

请检查图像 在此输入图像描述

And*_*rew 45

用:

<Text style={{textDecorationLine: 'line-through', textDecorationStyle: 'solid'}}>
  Solid line-through
</Text>
Run Code Online (Sandbox Code Playgroud)


ale*_*ger 7

<Text style={{ textDecorationLine: 'line-through' }}>Strike through text</Text>
Run Code Online (Sandbox Code Playgroud)

您可以在此处的官方文档中找到更多文本样式选项


小智 5

您可以使用textDecorationLine“line-through”属性,如下所示:

<Text style={{ textDecorationLine: 'line-through' }}>$12</Text>
Run Code Online (Sandbox Code Playgroud)

它会在你的文字上放一条线!


Har*_*ngh 5

那么你想实现这个目标吗?

在此输入图像描述

<Text style={styles.oldPrice}>$19.19</Text>
Run Code Online (Sandbox Code Playgroud)

只需将此样式传递给文本组件即可

const styles = StyleSheet.create({
  oldPrice: {
    textDecorationLine: 'line-through',
    textDecorationStyle: 'solid',
  },
});
Run Code Online (Sandbox Code Playgroud)