antd table localeCompare 中文排序的问题

用的是ant design 的table 想法是前端按照拼音对中文排序。排序函数官网就是这样写的。但是报错说TypeError: a.localeCompare is not a function。
该怎么修改。

columns = [
    {
      title: '公司名称',
      dataIndex: 'companyname',
      key: 'companyname',
      sorter: (a, b) => a.localeCompare(b),
    },
 ]
阅读 7.9k
2 个回答

检查 a 的值是不是字符串

a是当前行的对象,要访问a[要排序的列名] - b[要排序的列名]

推荐问题