vue数据两个相同的参数对比只显示第一个
如每条的rq0/rq1对比
data() {
return{
dataList: [
{
CurrencyName: "现金",
rq0: "2017-10-20 19:22:17",
rq1: "2018-02-07 19:48:00",
yje: -1179.8
},
{
CurrencyName: "微支付",
rq0: "2017-10-20 19:22:17",
rq1: "2018-02-07 19:48:00",
yje: 0.06
},
{
CurrencyName: "礼券",
rq0: "2017-10-20 19:22:17",
rq1: "2018-02-07 19:48:00",
yje: 16
},
{
CurrencyName: "现金",
rq0: "2021-01-29 09:05:34",
rq1: "2024-03-12 15:31:00",
yje: 2945.64
},
{
CurrencyName: "储卡",
rq0: "2021-01-29 09:05:34",
rq1: "2024-03-12 15:31:00",
yje: 1523.71
},
{
CurrencyName: "现金",
rq0: "2024-04-12 09:39:30",
rq1: "2025-03-17 15:36:00",
yje: 1041.88
},
{
CurrencyName: "微支付",
rq0: "2024-04-12 09:39:30",
rq1: "2025-03-17 15:36:00",
yje: 0.01
},
{
CurrencyName: "礼券",
rq0: "2024-04-12 09:39:30",
rq1: "2025-03-17 15:36:00",
yje: 30.3
},
],
processedData: [],
}
}
methods:{
pData() {
const seen = new Set();
const processed = JSON.parse(JSON.stringify(this.dataList));
processed.forEach(item => {
const key = `${item.rq0}-${item.rq1}`;
if (seen.has(key)) {
item.rq0 = "0";
item.rq1 = "0";
} else {
seen.add(key);
}
});
this.processedData = processed;
console.log(this.processedData)
},
}
