javascript - 如何在vuejs中拼接嵌套数组
问题描述
我的查询结果
absent: 0
attn: {21: {days: 5}, 22: {days: 5}, 23: {days: 3}}
daily_rate: 57.50798722044728
deduction: {4: {amount: 333.33}, 6: {amount: 222.2, },…}
4: {amount: 333.33,}
6: {amount: 222.2}
7: {amount: 2242}
8: {amount: 1127.5}
9: {amount: 1120}
在我的 vue js 中,我有父数组和子数组..我不知道如何在嵌套数组中拼接数据
<tbody>
<tr v-for="(fetch, count) in payrollPayableArray"> -----> PARENT ARRAY
<td style="height:10px;">{{fetch.pay_class}}</td>
<td style="height:10px; color:red;">{{formatNum(fetch.absent * fetch.daily_rate)}}</td>
<td style="height:10px; color:red;">{{formatNum(fetch.late * fetch.rate_per_minute)}}</td>
<td style="height:10px; color:red;">{{formatNum(fetch.ut * fetch.rate_per_minute)}}</td>
<td style="height:10px;">{{formatNum(fetch.gross)}}</td>
<template v-for="(disp, index) in fetch.deduction"> --> CHILD ARRAY
<td>{{disp.amount}} <button type="button" @click="removeDeduction(index)"class="btn btn-danger btn-sm">X</button> </td>
</template>
</tr>
</tbody>
这个功能不起作用......我希望你能帮助我
removeDeduction(index) {
return this.payrollPayableArray.reduce((acc,item)=>{
const arr = Object.values(item.deduction).reduce((bcc,a,idx)=>{
Object.values(idx).splice(index,1)
})
})
},
我的问题类似于此https://jsfiddle.net/uLqfks3e/5/
解决方案
推荐阅读
- asp.net - 如何从 Sharepoint 中提取信息并显示在使用 ASP.net 和 HTML 构建的单独网站上
- git - 如何修复“您的分支比 'origin/master' 领先 1 次提交。”?
- r - 使用 R 中的网状包访问 python 库和函数
- java - Glassfish 3 将所有 http 请求重定向到 https
- mysql - MySQL JSON“不在”不起作用
- android - 匕首安卓工作室3
- c++ - C++11 整数初始化
- android - 即使发生操作,改造 onResponse 也不会出错
- redux-form - 在 onChange 中反跳提交表单
- regex - 如何使用正则表达式替换给定指定前缀的字符串部分