Changed parameters of sort method of Table
This commit is contained in:
parent
e49f796318
commit
da020a63ee
2 changed files with 10 additions and 2 deletions
|
@ -436,7 +436,7 @@
|
||||||
const key = this.cloneColumns[index].key;
|
const key = this.cloneColumns[index].key;
|
||||||
data.sort((a, b) => {
|
data.sort((a, b) => {
|
||||||
if (this.cloneColumns[index].sortMethod) {
|
if (this.cloneColumns[index].sortMethod) {
|
||||||
return this.cloneColumns[index].sortMethod(a, b);
|
return this.cloneColumns[index].sortMethod(a[key], b[key], type);
|
||||||
} else {
|
} else {
|
||||||
if (type === 'asc') {
|
if (type === 'asc') {
|
||||||
return a[key] > b[key] ? 1 : -1;
|
return a[key] > b[key] ? 1 : -1;
|
||||||
|
|
|
@ -16,7 +16,15 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '年龄',
|
title: '年龄',
|
||||||
key: 'age'
|
key: 'age',
|
||||||
|
sortable: true,
|
||||||
|
sortMethod: function (a, b, type) {
|
||||||
|
if (type === 'asc') {
|
||||||
|
return a < b ? 1 : -1;
|
||||||
|
} else if (type === 'desc') {
|
||||||
|
return a > b ? 1 : -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '地址',
|
title: '地址',
|
||||||
|
|
Loading…
Add table
Reference in a new issue