TextInput常用屬性
- value
文本輸入的默認值,賦值後UI不能修改
- keyboardType
鍵盤類型,enum(‘default’, “ascii-capable”, ‘numbers-and-punctuation’, ‘url’, ‘number-pad’, ‘phone-pad’, ‘name-phone-pad’, ‘email-address’, ‘decimal-pad’, ‘twitter’, ‘web-search’, “numeric”)
- multiline
如果值爲真,文本輸入可以輸入多行。默認值爲假
- password
如果值爲真,文本輸入框就成爲一個密碼區域。默認值爲假
注:如果設置了多行,那麼這個屬性不適用
- placeholder
在文本輸入之前字符串將被呈現出來,通常被稱爲佔位文字
- placeholderTextColor
佔位文字的顏色
- clearButtonMode
清除按鈕出現在文本視圖右側的時機(‘never’, ‘while-editing’, ‘unless-editing’, ‘always’)
<View style={styles.container}>
<TextInput
style = {styles.inputStyle}
value = 'UI改不來'
keyboardType = 'number-pad'
multiline = {true}
password = {true}
placeholder = '佔位文字'
clearButtonMode = 'always'
>
</TextInput>
</View>