数组按照每个对象的属性值的大小进行排序
数组按照每个对象的属性值的大小进行排序
let arr = this.data
arr.sort(this.compare('avgScore'))
compare (property) {
return function (a, b) {
var value1 = a[property]
var value2 = b[property]
return value2 - value1
}
},
分割数组为[[],[],[]]
// 分割数组
splitData (num, arr) {
if (this[arr].length < num) {
return [this[arr]]
} else {
const times = Math.ceil(this[arr].length / num)
const newArr = []
for (let i = 0; i <= times; i++) {
if (i * num >= this[arr].length) {
break
}
newArr.push(this[arr].slice(i * num, (i + 1) * num))
}
return newArr
}
},