本文介绍了如何在 React Native 中将文本设为粗体、斜体或下划线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
令人惊讶的是,Stack Overflow 上还没有一个问题可以将这些问题组合在一起;SO 上没有斜体或下划线的答案,实际上只有 这个问题 为粗体.我在下面自己回答了这个问题.
Surprisingly there isn't one question that groups these all together yet on Stack Overflow; there hasn't been an answer on SO for italics or underline, in fact, only this question for bold. I self-answered this quesiton below.
推荐答案
<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'}
})
Snack 工作演示:https://snack.expo.io/BJT2ss_y7
Working demo on Snack: https://snack.expo.io/BJT2ss_y7
这篇关于如何在 React Native 中将文本设为粗体、斜体或下划线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!