Merge pull request from rijn/174

Changed parameters of sort method of Table
This commit is contained in:
Aresn 2017-01-16 15:34:58 +08:00 committed by GitHub
commit 6831b361ca
2 changed files with 10 additions and 2 deletions
src/components/table
test/routers

View file

@ -436,7 +436,7 @@
const key = this.cloneColumns[index].key;
data.sort((a, b) => {
if (this.cloneColumns[index].sortMethod) {
return this.cloneColumns[index].sortMethod(a, b);
return this.cloneColumns[index].sortMethod(a[key], b[key], type);
} else {
if (type === 'asc') {
return a[key] > b[key] ? 1 : -1;

View file

@ -16,7 +16,15 @@
},
{
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: '地址',