因此,我将reminder componenttextInput 从 react-native 导入,DatePicker 从本机库导入,还有一个按钮将在单击事件时保存表单。
现在,当我点击日期选择器,它提供了一个错误说:value for date cannot be cast from string to double。我还附上了错误的屏幕截图。
不知道我哪里出错了。
这是组件的代码。
class Reminder extends Component {
constructor(props) {
super(props);
let formatDate = new Date();
this.state = {
chosenDate: formatDate.toISOString().split('T')[0],
text: '',
};
this.handleChangeInput = this.handleChangeInput.bind(this);
this.saveData = this.saveData.bind(this);
}
render() {
const {chosenDate} = this.state;
return (
<View>
<Form style={styles.formContainer}>
<View style={styles.formView}>
< TextInput
placeholder = "Set your reminder"
onChangeText={this.handleChangeInput}
value={this.state.text}
/>
<DatePicker
defaultDate={chosenDate}
mode = "date"
animationType={"fade"}
androidMode={"default"} …Run Code Online (Sandbox Code Playgroud)