首页 > 技术文章 > iview table数据排序不正确

victory820 2018-07-24 10:09 原文

在使用iview的table组件时,要做排序

代码:

sortable: true,
sortMethod: (a, b, type) => {
if (type === 'desc') {
return parseInt(a) < parseInt(b) ? 1 : -1
} else {
return parseInt(a) > parseInt(b) ? 1 : -1
}
}

这里需要注意的是要返回1或者-1

 

推荐阅读