我在网页中使用 Vue,我希望表数据值是已打印到表中某个 div 中的值的滚动总和
我希望避免计算或对数据本身进行任何操作,但我想将任何已打印在 div 中的值与 id 相加,totals
然后将它们加起来作为我的评论所在的总计
我可以像这样在 vue 中根据 div id 汇总值吗?
我的代码:
<tr v-for="(value, warehouse) in numbersByWarehouse" :key="warehouse">
<td>@{{warehouse}}</td>
<td v-for="date in dates" :key="date" >
<div v-for="(dataByDate, dateValue) in value.dates" :key="dateValue">
<div id="totals" v-if="dateValue == date ">
@{{dataByDate.total_categories}}
</div>
</div>
</td>
<td>
<!-- I want this to be a total of all values for @{{dataByDate.total_categories }} in div ID totals -->
</td>
</tr>
//here's the returned object for reference
numbersByWarehouse() {
warehouseRows = [
{
"13401 - TEST ":{
"dates":{
"2021-11-11":{
"categories":420,
"qty":1,
"total_categories":420,
}
},
},
]
console.log(warehouseRows)
return warehouseRows
},