【问题标题】:Cannot see UI in react-native for <TextInput>在 <TextInput> 的 react-native 中看不到 UI
【发布时间】:2020-04-02 06:31:13
【问题描述】:

我从 React-Native 开始。我能够看到&lt;Text&gt;。然后我继续添加我的&lt;TextInput&gt;

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

export default class App extends Component {

  state = {
    placeName: ''
  }

  placeNameChangedHandler = event => {
    alert(event)
  }

  render(){
    return (
      <View style={styles.container}>
        <Text>Ayman</Text>
        <TextInput 
          style={{width:300, borderColor:"black"}}
          value={this.state.placeName}
          onChangeText={this.placeNameChangedHandler}
        />
      </View>
    );
  }

}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

我可以捆绑我的 Javascript 应用程序,但 UI 显示一个空白屏幕。

请注意,我是新手,我在手机上使用expo 作为 UI 设备。

【问题讨论】:

  • 你能添加截图你得到什么
  • 你可以尝试设置TextInput值和占位符一个init值。

标签: reactjs react-native user-interface textinput


【解决方案1】:

TextInput 样式中添加borderWidth: 1,它将显示空文本输入。

【讨论】:

    猜你喜欢
    • 2021-10-12
    • 2023-02-25
    • 2021-07-12
    • 1970-01-01
    • 2022-12-23
    • 1970-01-01
    • 1970-01-01
    • 2021-08-11
    • 2016-04-11
    相关资源
    最近更新 更多