React-Native 不能用非大写字母写首字母
React-Native cannot write first letter with noncapital
我在使用 react-native 时遇到了一些问题。我有一个输入组件(如文本字段)供用户输入他的电子邮件地址,但问题是,首字母始终默认为大写字母,并且不可能将其设置为非大写字母。我怎样才能改变它,就像第一个字母也可以很小一样?
TextInput 有 autoCapitalize
来处理这个。
`autoCapitalize enum('none', 'sentences', 'words', 'characters')`
例如这样尝试:
<TextInput
placeholder=""
placeholderTextColor='rgba(28,53,63, 1)'
autoCapitalize='none'
value='test'
/>
如果您无法使用 TextInput
将所有字母设为大写,那么您可以使用 autoCapitalize = 'characters'
,如果您只想将第一个字符设为大写,则使用 autoCapitalize = 'words'
。但是,请确保您没有设置 keyboard type 属性.
确保 属性 autoCorrect
是 false
。这样它就不会大写第一个电子邮件字符。此外,将 keyboardType
设置为 email-address
可显示可访问 @ 选项的键盘。我就是这样做的:
<TextInput
textContentType='emailAddress'
keyboardType='email-address'
autoCapitalize='none'
autoCorrect={false}
autoCompleteType='email'
/>
我在使用 react-native 时遇到了一些问题。我有一个输入组件(如文本字段)供用户输入他的电子邮件地址,但问题是,首字母始终默认为大写字母,并且不可能将其设置为非大写字母。我怎样才能改变它,就像第一个字母也可以很小一样?
TextInput 有 autoCapitalize
来处理这个。
`autoCapitalize enum('none', 'sentences', 'words', 'characters')`
例如这样尝试:
<TextInput
placeholder=""
placeholderTextColor='rgba(28,53,63, 1)'
autoCapitalize='none'
value='test'
/>
如果您无法使用 TextInput
将所有字母设为大写,那么您可以使用 autoCapitalize = 'characters'
,如果您只想将第一个字符设为大写,则使用 autoCapitalize = 'words'
。但是,请确保您没有设置 keyboard type 属性.
确保 属性 autoCorrect
是 false
。这样它就不会大写第一个电子邮件字符。此外,将 keyboardType
设置为 email-address
可显示可访问 @ 选项的键盘。我就是这样做的:
<TextInput
textContentType='emailAddress'
keyboardType='email-address'
autoCapitalize='none'
autoCorrect={false}
autoCompleteType='email'
/>