相关疑难解决方法(0)

反应原生错误:日期值不能从字符串转换为双精度

因此,我将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)

javascript reactjs react-native

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

标签 统计

javascript ×1

react-native ×1

reactjs ×1