如何将反应日期选择器的语言更改为德语?



我正在尝试将<DateRangePicker/>更改为德语。我做错了什么?

render(){
moment.locale('de')
return(
<DateRangePicker
startDate={this.state.startDate} // momentPropTypes.momentObj or null,
endDate={this.state.endDate} // momentPropTypes.momentObj or null,
onDatesChange={({ startDate, endDate }) => {
this.setState({ endDate, startDate,
startDateString: startDateString,
endDateString: endDateString})}} // PropTypes.func.isRequired,
focusedInput={this.state.focusedInput} // PropTypes.oneOf([START_DATE, END_DATE]) or null,
onFocusChange={focusedInput => this.setState({ focusedInput }) } // PropTypes.func.isRequired,
endDatePlaceholderText={"Bis"}
startDatePlaceholderText={"Ab"}
displayFormat={"DD/MM/YYYY"}
showDefaultInputIcon={false}
/>
)
}

要为react-dates设置语言,有两种方法可以做到这一点:

1.

import moment from 'moment';
componentDidMount() {
moment.locale('ge');
}
  1. import 'moment/locale/ge'

确保在你的 npm 时刻 js 中,并将其导入到该日期选择器的组件中

最新更新