ant-design/components/datepicker/demo/locale.md

38 lines
702 B
Markdown
Raw Normal View History

# 国际化
- order: 9
2015-11-16 14:10:42 +08:00
通过 `locale` 配置时区、语言等, 默认支持 en_US, zh_CN
---
````jsx
import { Datepicker } from 'antd';
2015-11-16 14:10:42 +08:00
import enUS from 'antd/lib/datepicker/locale/en_US';
function assign(target, source) {
for(var s in source) {
target[s] = source[s];
}
return target;
}
const App = React.createClass({
getInitialState() {
return {
2015-11-16 14:10:42 +08:00
locale: assign({
timezoneOffset: 0 * 60,
firstDayOfWeek: 0,
2015-11-16 14:10:42 +08:00
minimalDaysInFirstWeek: 1
}, enUS)
};
},
render() {
return <Datepicker showTime={true} locale={this.state.locale} />;
}
});
ReactDOM.render(<App />, document.getElementById('components-datepicker-demo-locale'));
````