Typescript 需要在键盘上单击两次以避免查看,即使在键盘应打开的情况下也应始终单击鼠标
我使用键盘AvoidgView将按钮与键盘一起向上移动,其中我有一个scrollview,其中Keybord设置为始终,PersistTaps设置为始终,在scrollview中,我使用的是Formik表单。我仍然必须双击一个按钮两次,才能让键盘关闭并提交我的数据。我一直试图手动关闭/处理scrollview上的键盘,但运气不好,我应该尝试其他方法吗Typescript 需要在键盘上单击两次以避免查看,即使在键盘应打开的情况下也应始终单击鼠标,typescript,react-native,formik,Typescript,React Native,Formik,我使用键盘AvoidgView将按钮与键盘一起向上移动,其中我有一个scrollview,其中Keybord设置为始终,PersistTaps设置为始终,在scrollview中,我使用的是Formik表单。我仍然必须双击一个按钮两次,才能让键盘关闭并提交我的数据。我一直试图手动关闭/处理scrollview上的键盘,但运气不好,我应该尝试其他方法吗 <KeyboardAvoidingView style={{ flex: 1 }} behavior={'padding'}>
<KeyboardAvoidingView style={{ flex: 1 }} behavior={'padding'}>
<ScrollView contentContainerStyle={{ flexGrow: 1 }} keyboardShouldPersistTaps={'always'}>
<Formik
initialValues={this.state}
validationSchema={this.schema}
onSubmit={(values, actions) => {
actions.setSubmitting(false);
}}
render={({ handleBlur, handleChange, handleSubmit, values, isValid }) => {
return (
<View style={onboardingStyles.inputContainer}>
<View>
<Text theme={theme} style={onboardingStyles.headerText}>
{i18n.t('phone_verify')}
</Text>
<TextInput
activeHighlight
value={RizeCore.util.formatPhoneDOM(values.phone)}
onChangeText={(val: string) => {
const phone = RizeCore.util.parseOutDigits(val, 10);
return handleChange('phone')(phone);
}}
onBlur={() => handleBlur('phone')}
label={i18n.t('phone_number')}
style={onboardingStyles.input}
labelStyle={{ color: 'white' }}
keyboardType={Platform.OS === 'web' ? 'default' : 'number-pad'}
returnKeyType="done"
/>
</View>
<BottomFixedCTA
ctaLabel={i18n.t('phone_send_code')}
loading={smsCodeIsBusy}
disabled={!isValid}
onPress={handleSubmit as undefined}
onBackPress={this._navSignUp}
/>
</View>
);
}}
/>
</ScrollView>
</KeyboardAvoidingView>
{
动作。设置提交(错误);
}}
render={({handleBlur,handleChange,handleSubmit,values,isValid})=>{
返回(
{i18n.t('phone_verify')}
{
const phone=RizeCore.util.parseOutDigits(val,10);
返回handleChange(“电话”)(电话);
}}
onBlur={()=>handleBlur('phone')}
label={i18n.t('phone_number')}
style={onboardingStyles.input}
labelStyle={{color:'white'}}
键盘类型={Platform.OS=='web'?'default':'number pad'}
returnKeyType=“完成”
/>
);
}}
/>
尝试使用:
keyboardShouldPersistTaps="handled"
您可以尝试向scroolview
keyboardShouldPersistTaps=“handled”
添加参数。虽然此代码可以回答问题,但最好解释如何解决问题,并提供代码作为示例或参考。纯代码的答案可能会令人困惑,并且缺乏上下文。我确实尝试过使用它,但遗憾的是没有实际的更改