【发布时间】:2018-08-01 23:10:27
【问题描述】:
我正在使用 react-multiple-datepicker。但我无法清除分配后的值。
从“react-multiple-datepicker”导入 MultipleDatePicker;
从“反应”导入反应;
class Addjob extends React.Component {
constructor(props) {
super(props);
this.state ={
selectedDays:[]
};
this.displayDates=this.displayDates.bind(this);
}
displayDates(dates) {
console.log("selected dates:"+ dates);
console.log(typeof dates);
dates.forEach(function(x) {
var d = new Date(x),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
console.log(year);
console.log(day);
console.log(month);
y.push([year, month, day].join('-'));
a=JSON.stringify(y);
a=a.replace("[","");
a=a.replace("]","");
a=a.replace(/\"/g, "") ;
});
this.setState({selectedDays:a});
}
render() {
return(
<MultipleDatePicker className="multipicker" onSubmit={this.displayDates} id="multidatepicker"/>
);
}
}
【问题讨论】:
-
能否提供更多代码。你是如何设置日期值的?
标签: javascript node.js html reactjs css