const datas = reactive({
monthlyDatas: [] as Array<{ id: number, date: string, category: string, amount: number }>
});
const getConsumeLists = () => {
let params = {};
Api.consumedetails.getAll(params)
.then(response => {
if (response.status === 200) {
datas.monthlyDatas = response.data.results;// 提取出来的数据在 response.data.results
}
})
.catch(error => {
console.error("Error fetching consume lists:", error);
});
};
返回格式是
0: {id: 1, consumepurpose: {…}, consumetype: {…}, date: '2024-04-01', category: '쇼핑', …}
1: {id: 2, consumepurpose: {…}, consumetype: {…}, date: '2024-04-01', category: '식비', …}
2: {id: 3, consumepurpose: {…}, consumetype: {…}, date: '2024-04-02', category: '주거', …}
3: {id: 4, consumepurpose: {…}, consumetype: {…}, date: '2024-04-02', category: '간식', …}
4: {id: 5, consumepurpose: {…}, consumetype: {…}, date: '2024-04-02', category: '식비', …}
5: {id: 6, consumepurpose: {…}, consumetype: {…}, date: '2024-04-02', category: '소송', …}
6: {id: 7, consumepurpose: {…}, consumetype: {…}, date: '2024-04-03', category: 'X', …}
7: {id: 8, consumepurpose: {…}, consumetype: {…}, date: '2024-04-03', category: '간식', …}
8: {id: 9, consumepurpose: {…}, consumetype: {…}, date: '2024-04-03', category: '식비', …}
9: {id: 10, consumepurpose: {…}, consumetype: {…}, date: '2024-04-03', category: '식비', …}
10: {id: 11, consumepurpose: {…}, consumetype: {…}, date: '2024-04-03', category: '간식', …}
11: {id: 12, consumepurpose: {…}, consumetype: {…}, date: '2024-04-04', category: '소송', …}
12: {id: 13, consumepurpose: {…}, consumetype: {…}, date: '2024-04-04', category: '식비', …}
13: {id: 14, consumepurpose: {…}, consumetype: {…}, date: '2024-04-04', category: '간식', …}
14: {id: 15, consumepurpose: {…}, consumetype: {…}, date: '2024-04-04', category: '생활', …}
15: {id: 16, consumepurpose: {…}, consumetype: {…}, date: '2024-04-05', category: '교통', …}
我要按照date进行月份对price求和,且显示当前月份的price的总和