屬性
numberOfLines 文本行數(shù)限制,添加后超過限制行數(shù)文本會在末尾默認以...的形式省略。
ellipsizeMode 設置文本縮略格式,配合numberOfLines使用,values:
- tail:在末尾...省略(默認值)
- clip:在末尾切割,直接切割字符無省略符
- head:在前面...省略
- middle:在中間...省略
onPress 點擊事件
style 樣式
樣式
color 字體顏色
fontSize 字體大小
fontFamily 字體
fontStyle 字的樣式 (normal:正常 italic:斜體)
fontWeight 設置粗體(normal:正常 bold:粗體100,200,300, 400, 500, 600, 700, 800, 900)
6.lineHeight 行高
7.textAlign 文字對其方式(auto:自動對齊left:左對齊right:右對齊 center:居中對齊)
8: textDecorationLine 下劃線和刪除線樣式(none:無線underline:下劃線line-through:刪除線 underline line-through:下劃線和刪除線)
export default class Lession01 extends Component {
onVBTextClick() {
console.log('--click--');
}
render() {
return (
<View style={styles.container}>
<Text
style={styles.vb_text}
numberOfLines={2}
onPress={this.onVBTextClick}
ellipsizeMode='tail'
>
On Thanksgiving, celebrated in America on the last Thursday of November,
friends and families gather around tables to feast and give thanks.
This holiday has origins dating back nearly 400 years when early American
settlers met the Native American Wampanoag people.
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
vb_text: {
color: '#333333',
fontFamily: 'Times',
margin: 10,
fontSize: 12,
textAlign: 'auto',
lineHeight: 22, //行高
fontStyle: 'italic', //設置文字:normal:正常體;italic:斜體
fontWeight: 'bold', //設置粗體 字,'normal' /*default*/, 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'
textDecorationLine: 'underline line-through',//下劃線和刪除線的樣式:['none' /*default*/, 'underline', 'line-through', 'underline line-through'
},
});