iview table数据排序不正确

在使用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

原文地址:https://www.cnblogs.com/victory820/p/9358463.html