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

1007 B

国际化

  • hidden: true

locale 设置表格的排序、过滤按钮的文字或 title


import { Table } from 'antd';

const columns = [{
  title: 'Name',
  dataIndex: 'name',
  filters: [{
    text: 'Starts with A',
    value: '^[aA]'
  }, {
    text: 'Starts with B',
    value: '^[bB]'
  }],
  onFilter: function(value, record) {
    return new RegExp(value).test(record.name);
  },
}, {
  title: 'Age',
  dataIndex: 'age',
  sorter: function(a, b) {
    return a.age - b.age;
  }
}, {
  title: 'Address',
  dataIndex: 'address'
}];

const data = [{
  key: '1',
  name: 'Alice',
  age: 32,
  address: 'Somewhere'
}, {
  key: '2',
  name: 'Bob',
  age: 42,
  address: 'Somewhere'
}, {
  key: '3',
  name: 'Candy',
  age: 32,
  address: 'Somewhere'
}];

const locale = {
  filterTitle: 'Filter',
  filterConfirm: 'Confirm',
  filterReset: 'Reset',
  emptyText: 'No Data',
};

ReactDOM.render(
  <Table columns={columns} dataSource={data} locale={locale} />,
  mountNode
);