Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/463.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 当使用键盘类型“聚焦于输入字段时,内容向下滚动;“违约”;在世博会上,我是土生土长的_Javascript_React Native_Expo - Fatal编程技术网

Javascript 当使用键盘类型“聚焦于输入字段时,内容向下滚动;“违约”;在世博会上,我是土生土长的

Javascript 当使用键盘类型“聚焦于输入字段时,内容向下滚动;“违约”;在世博会上,我是土生土长的,javascript,react-native,expo,Javascript,React Native,Expo,我有一个ScrollView组件,其中有一个表单(和)。这个表单有一些输入字段( 这是我的代码: AppFormField(主屏幕) 函数ActivityFormScreen({navigation}){ 返回( handleSubmit(表格)} validationSchema={validationSchema} 初始值={{ fecha:getFormValue(“fecha”), finca_id:getFormValue(“finca_id”), lote:getFormValue(

我有一个
ScrollView
组件,其中有一个表单(
和)。这个表单有一些输入字段(

这是我的代码:

AppFormField(主屏幕)

函数ActivityFormScreen({navigation}){
返回(
handleSubmit(表格)}
validationSchema={validationSchema}
初始值={{
fecha:getFormValue(“fecha”),
finca_id:getFormValue(“finca_id”),
lote:getFormValue(“lote”),
cosecha:getFormValue(“cosecha”),
cultivos:getFormValue(“cultivos”),
maquinaria:getFormValue(“maquinaria”),
tiempo_actividad:getFormValue(“tiempo_actividad”),
productos:getFormValue(“productos”),
cantidad:getFormValue(“cantidad”),
unidad:getFormValue(“unidad”),
公顷面积:getFormValue(“公顷面积”),
trabajos:getFormValue(“trabajos”),
observaciones:getFormValue(“observaciones”),
}}
>
.
.
.
);
}
const styles=StyleSheet.create({
容器:{
背景颜色:“白色”,
弹性:1,
辩护内容:“中心”,
marginHorizontal:10,
//paddingTop:50,
},
});
AppFormField

import React from "react";
import { useFormikContext } from "formik";
import { StyleSheet, View } from "react-native";

import AppTextInput from "../AppTextInput";
import ErrorMessage from "./ErrorMessage";

function AppFormField({ placeholder, name, width, holder, ...otherProps }) {
  const { setFieldTouched, handleChange, errors, touched } = useFormikContext();
  return (
    <View style={styles.container}>
      <AppTextInput
        onBlur={() => setFieldTouched(name)}
        onChangeText={handleChange(name)}
        width={width}
        holder={holder}
        placeholder={placeholder}
        {...otherProps}
      />
      <ErrorMessage error={errors[name]} visible={touched[name]} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    marginBottom: 20,
    marginHorizontal: 20,
  },
});

export default AppFormField;

从“React”导入React;
从“formik”导入{useFormikContext};
从“react native”导入{StyleSheet,View};
从“./AppTextInput”导入AppTextInput;
从“/ErrorMessage”导入ErrorMessage;
函数AppFormField({占位符、名称、宽度、持有者,…otherProps}){
const{setfieldtoucted,handleChange,errors,toucted}=useFormikContext();
返回(
setFieldTouched(名称)}
onChangeText={handleChange(名称)}
宽度={width}
holder={holder}
占位符={占位符}
{…其他道具}
/>
);
}
const styles=StyleSheet.create({
容器:{
marginBottom:20,
marginHorizontal:20,
},
});
导出默认AppFormField;
AppTextInput

import React from "react";
import { StyleSheet, View, TextInput, Text, Keyboard } from "react-native";

function AppTextInput({ placeholder = " ", holder, ...otherProps }) {
  return (
    <View style={styles.container}>
      <Text style={styles.holder}>{holder}</Text>
      <TextInput
        style={styles.input}
        placeholder={placeholder}
        returnKeyLabel="Listo"
        returnKeyType="done"
        onSubmitEditing={Keyboard.dismiss}
        {...otherProps}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    backgroundColor: "transparent",
  },
  holder: {
    fontSize: 20,
    textAlign: "left",
    color: "#000",
    opacity: 0.6,
    width: "100%",
    height: 30,
  },
  input: {
    fontSize: 20,
    borderBottomWidth: 1,
    borderColor: "#D9D5DC",
    width: "100%",
  },
});

export default AppTextInput;

从“React”导入React;
从“react native”导入{样式表、视图、文本输入、文本、键盘};
函数AppTextInput({placeholder=”“,holder,…otherProps}){
返回(
{holder}
);
}
const styles=StyleSheet.create({
容器:{
背景色:“透明”,
},
持有人:{
尺寸:20,
textAlign:“左”,
颜色:“000”,
不透明度:0.6,
宽度:“100%”,
身高:30,
},
输入:{
尺寸:20,
边界宽度:1,
边框颜色:“D9D5DC”,
宽度:“100%”,
},
});
导出默认AppTextInput;
已解决:

出于某种原因,我的
ScrollView
组件将属性
paddingBottom
设置为500,只需删除它,我就解决了这个问题

import React from "react";
import { StyleSheet, View, TextInput, Text, Keyboard } from "react-native";

function AppTextInput({ placeholder = " ", holder, ...otherProps }) {
  return (
    <View style={styles.container}>
      <Text style={styles.holder}>{holder}</Text>
      <TextInput
        style={styles.input}
        placeholder={placeholder}
        returnKeyLabel="Listo"
        returnKeyType="done"
        onSubmitEditing={Keyboard.dismiss}
        {...otherProps}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    backgroundColor: "transparent",
  },
  holder: {
    fontSize: 20,
    textAlign: "left",
    color: "#000",
    opacity: 0.6,
    width: "100%",
    height: 30,
  },
  input: {
    fontSize: 20,
    borderBottomWidth: 1,
    borderColor: "#D9D5DC",
    width: "100%",
  },
});

export default AppTextInput;