Reactjs 在react native中使用onChangeText事件的属性处理对象
我是react native的新手,不知道如何处理当前的案例,我已经花了很多时间寻找解决方案。我有以下几点:Reactjs 在react native中使用onChangeText事件的属性处理对象,reactjs,react-native,Reactjs,React Native,我是react native的新手,不知道如何处理当前的案例,我已经花了很多时间寻找解决方案。我有以下几点: 构造函数(道具){ 超级(道具); 此.state={ 新注释:{title:'',description:'',dateToRead:null}, modalVisible:false }; } 如何在TextInput中保存onChangeText事件的值?在react native中正确处理属性吗?处理文本输入数据的两种方法 <TextInput onChange={(
构造函数(道具){
超级(道具);
此.state={
新注释:{title:'',description:'',dateToRead:null},
modalVisible:false
};
}
如何在TextInput中保存
onChangeText
事件的值?在react native中正确处理属性吗?处理文本输入数据的两种方法
<TextInput
onChange={(event) =>
this.setState({newNote: {...this.state.newNote,
title: event.nativeEvent.text}}
)}
value={this.state.newNote.title}
/>
this.setState({newNote:{…this.state.newNote,
标题:event.nativeEvent.text}
)}
值={this.state.newNote.title}
/>
或
this.setState({newNote:{…this.state.newNote,description:text}
)}
值={this.state.newNote.description}
/>
谢谢,这对我很有效,但什么方法更好?在react-native中以这种方式处理数据可以吗?它们都适用于react-native,并且它们是相等的,您可以使用任何
<TextInput
onChangeText={(text) =>
this.setState({newNote: {...this.state.newNote,description: text}}
)}
value={this.state.newNote.description}
/>