如何计算数组中的总数?
我将数据作为props 传递给子组件,我被困在这里.当我控制台log prop时,它返回一个非常复杂的对象.我try 了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>