如何計算數組中的總數?Vue.js如何計算總數?
我將數據作爲道具傳遞給子組件,並且我卡在這裏。當我控制日誌道具時,它會返回一個非常複雜的對象。我試過this.values.reduce()
函數,但它不起作用。
<template>
<tr v-for="value in values" >
<th scope="row">{{$index+1}}</th>
<td>{{value.name}}</td>
<td>-</td>
<td>${{value.total}}</td>
</tr>
<tr>
<th></th>
<td><strong>Total:{{total}}</strong></td>
<td>-</td>
<td>-</td>
</tr>
</template>
<script>
export default {
props: ['values'],
ready: function() {
}
}
</script>
作品在這裏,請分享更多的代碼 – gurghet