mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 11:08:45 +08:00
docs: Fix LocelProvider demo
This commit is contained in:
parent
dd628655de
commit
6f9c8da502
@ -17,9 +17,9 @@ Components which need localization support are listed here, you can toggle the l
|
||||
import { LocaleProvider, Pagination, DatePicker, TimePicker, Calendar,
|
||||
Popconfirm, Table, Modal, Button, Select, Transfer, Radio } from 'antd';
|
||||
import zhCN from 'antd/lib/locale-provider/zh_CN';
|
||||
import enUS from 'antd/lib/locale-provider/en_US';
|
||||
import moment from 'moment';
|
||||
import 'moment/locale/zh-cn';
|
||||
moment.locale('en');
|
||||
|
||||
const Option = Select.Option;
|
||||
const RangePicker = DatePicker.RangePicker;
|
||||
@ -108,25 +108,20 @@ class App extends React.Component {
|
||||
constructor() {
|
||||
super();
|
||||
this.state = {
|
||||
locale: null,
|
||||
locale: enUS,
|
||||
};
|
||||
}
|
||||
changeLocale = (e) => {
|
||||
const localeValue = e.target.value;
|
||||
this.setState({ locale: localeValue });
|
||||
if (!localeValue) {
|
||||
moment.locale('en');
|
||||
} else {
|
||||
moment.locale('zh-cn');
|
||||
}
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<div className="change-locale">
|
||||
<span style={{ marginRight: 16 }}>Change locale of components: </span>
|
||||
<Radio.Group defaultValue={null} onChange={this.changeLocale}>
|
||||
<Radio.Button key="en" value={null}>English</Radio.Button>
|
||||
<Radio.Group defaultValue={enUS} onChange={this.changeLocale}>
|
||||
<Radio.Button key="en" value={enUS}>English</Radio.Button>
|
||||
<Radio.Button key="cn" value={zhCN}>中文</Radio.Button>
|
||||
</Radio.Group>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user