对于 elementui table 组件的排序 要求对每列数据进行排序 数据是 金额之类 数字的没问题 可是 针对 标题中有数字,字母,文字的时候 会排序错误ui
:sort-method="customeSort" customeSort(a,b){ let ret = 0; if((a.title.substring(0,1).toUpperCase()>='A' && a.title.substring(0,1).toUpperCase()<='Z') || (b.title.substring(0,1).toUpperCase()>='A' && b.title.substring(0,1).toUpperCase()<='Z')) { ret = a.title>b.title?1:-1; } else { ret = a.title.localeCompare(b.title,"zh"); } return ret; }