Json数据
private data: any[] = [
{
accountType: "R",
accountTypeDesc: "房间账1",
},
{
accountType: "N",
accountTypeDesc: "虚拟账2",
},
{
accountType: "R",
accountTypeDesc: "房间账2",
},
{
accountType: "X",
accountTypeDesc: "现付账1",
},
{
accountType: "X",
accountTypeDesc: "现付账2",
},
{
accountType: "N",
accountTypeDesc: "虚拟账1",
}
];
// 根据不同字段排序
this.data.sort(function (a, b) {
var x = "accountType"; //要排序字段
if (a[x] < b[x]) {
return -1;
}
if (a[x] > b[x]) {
return 1;
}
return 0;
});
// console.log(this.data);
}
网友评论