【问题标题】:How to 'edit page' with react native?如何用本机反应“编辑页面”?
【发布时间】:2021-04-23 11:07:39
【问题描述】:

我正在尝试使用本机反应制作一个编辑个人资料页面。例如,用户想要更改他/她的用户名,因此应该转到个人资料编辑页面。但是从数据库中获取数据后,我无法更新数据。 我尝试使用 TextInput 值道具。但是如果不点击它,它只会发送空值。你可以在下面看到我的代码。

   <View >
        <TextInput
          placeholder='Adres'
          placeholderTextColor='#808e9b'
          style={styles.biginput}
          multiline={true}
          numberOfLines={50}
          value={this.state.address} 
          onChangeText={Address => this.setState({ Address })}
        />
      </View>

我试着像下面这样使用。但它再次发送 null

       <View >

        <TextInput
          placeholder='İl'
          placeholderTextColor='#808e9b'
          style={styles.input}
          onChangeText={City => this.setState({ City })}
        >
          {this.state.city} 
        </TextInput>
      </View>

我应该如何更新数据?

【问题讨论】:

    标签: reactjs react-native axios


    【解决方案1】:

    我认为您在从服务器获取数据时没有设置初始值。因此,如果用户不触摸 textInput,则不会设置值,因此它们为空。获取数据时首先设置您的状态。

    【讨论】:

      猜你喜欢
      • 2020-11-20
      • 2018-09-08
      • 1970-01-01
      • 2019-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多