小编Aki*_*nda的帖子

react-native 键盘自动隐藏问题

目前,我正在开发一个 react-native 应用程序。问题是,当我触摸文本输入框时,只有每次重新启动我的应用程序时,键盘才会第一次自动隐藏。

我的 TextInput 组件在这里:

<TextInput
  blurOnSubmit={false}
  placeholder={"Email..."}
  autoCapitalize="none"
  style={{
    height: 40,
    paddingLeft: 10,
    fontSize: 18,
    fontWeight: "bold",
    width: "90%",
  }}
  onChangeText={(email) => {
    this.setState({ email });
    this.validateEmail(email).then((res) => this.handleResponse(res));
  }}
  value={this.state.email}
  ref={(ref) => (this.email = ref)}
  onSubmitEditing={() => this.mobile.focus()}
/>
Run Code Online (Sandbox Code Playgroud)

我的 Package.json 依赖项

  "dependencies": {
    "@react-native-community/async-storage": "^1.11.0",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-navigation/bottom-tabs": "^5.5.2",
    "@react-navigation/drawer": "^5.8.2",
    "@react-navigation/native": "^5.5.1",
    "@react-navigation/stack": "^5.5.1",
    "react": "16.11.0",
    "react-native": "0.62.2",
    "react-native-datepicker": "^1.7.2",
    "react-native-gesture-handler": "^1.6.1",
    "react-native-looped-carousel": "^0.1.13",
    "react-native-reanimated": "^1.9.0",
    "react-native-safe-area-context": "^3.0.5",
    "react-native-safe-area-view": "^1.1.1",
    "react-native-screens": "^2.8.0",
    "react-native-vector-icons": "^6.6.0"
  },
Run Code Online (Sandbox Code Playgroud)

keyboard react-native

6
推荐指数
1
解决办法
1101
查看次数

如何在 TextInput 中添加前缀 - React Native

我想在我的文本输入中添加前缀,我想知道如何做到这一点。

文本输入代码

        <TextInput
          style={styles.inputs}
          placeholder="Mobile Number"
          keyboardType="number-pad"
          underlineColorAndroid="transparent"
          onChangeText={mobile_number => this.setState({mobile_number})}
        />
Run Code Online (Sandbox Code Playgroud)

我想要的最终输出

维

textinput react-native react-native-ios

0
推荐指数
1
解决办法
1万
查看次数