Vue中对获取的数据进行重新排序

var Enumerable = require('linq'); // 使用linq

按照RegisterID排序
listJust是自己定义的数组,来接收数据。
listJust: []

addData(data) {
                let that = this
                if (this.listJust.length && this.listJust.length >= 5) {
                    // 数据超过5条后,继续增加数据的时候,将最早的数据清除
                    this.listJust.splice(this.listJust.length - 1, 1)
                    this.listJust.push(data);
                    this.listJust = Enumerable.from(this.listJust).orderByDescending("d=>d.RegisterID").toArray();
                } else {
                    this.listJust.push(data);
                    this.listJust = Enumerable.from(this.listJust).orderByDescending("d=>d.RegisterID").toArray();
                }
            },
原文地址:https://www.cnblogs.com/ahao214/p/11063438.html