令人惊讶的是,在 Stack Overflow 上没有一个问题将这些内容组合在一起; 在 SO 上没有斜体或下划线的答案,实际上,只有粗体的 这个问题。我在下面自我回答了这个问题。
<Text style={styles.bold}>I'm bold!</Text> <Text style={styles.italic}>I'm italic!</Text> <Text style={styles.underline}>I'm underlined!</Text> const styles = StyleSheet.create({ bold: {fontWeight: 'bold'}, italic: {fontStyle: 'italic'}, underline: {textDecorationLine: 'underline'} })
零食工作演示: https://snack.expo.io/BJT2ss_y7
<View style={styles.MainContainer}> <Text style={styles.TextStyle}>Example of Underline Text</Text> </View>
TextStyle: { textAlign: 'center', fontWeight: 'bold' fontStyle: 'italic' fontSize: 20, textDecorationLine: 'underline', //line-through is the trick },
只有一条线
<Text style=\{\{fontStyle: 'italic', fontWeight: 'bold', textDecorationLine: 'underline'}}>Bold, Italic & Underline Text</Text>
您可以在此页面中看到所有可能的 att Https://reactnative.dev/docs/text
比如说。
textDecorationLine: enum('none', 'underline', 'line-through', 'underline line-through')
只供使用
<Text style={styles.textStyle}>I'm Underline!</Text> const styles = StyleSheet.create({ textStyle: { textDecorationLine: 'underline' } })
其他装饰有: