VUE專案,從mongodb後臺獲取的物件陣列,前端對其進行排序
阿新 • • 發佈:2018-12-12
methods: {
//升序排序,js中方法
sortRole (pro) {
return function (a,b) {
var value1 = a[pro];
var value2 = b[pro];
return value1 - value2;
}
}
},
computed: {
dateTrans() {
//tableData後臺獲取的物件陣列
this.tableData = this.tableData.sort(this.sortRole('userId'))
}
}
陣列是這樣的:
[{
"_id": "5baf3543ec19c50cfc7d9e15",
"userId": 1005,
"name": "王五",
"hiredate": "2018-09-20T16:00:00.000Z",
"entryTo": "南京",
"currentCity": "Nj",
"projectTeam": "nj",
"status": "",
"consumer": "一般使用者",
"password": "666",
"addAccess": false,
"deleteAccess": false,
"updateAccess": false,
"findAccess": true
},………………]