<template>
<table>
<tr>
<td colspan="4">全校学生统计表</td>
</tr>
<tr>
<td>年级</td>
<td>班级数量</td>
<td>班级人数</td>
<td>年级人数</td>
</tr>
</table>
<table v-for="(index) in nj" :key="index">
<tr>
<td>{{ nj[index] }}</td>
<td>{{ bjCount[index] }}</td>
<td>{{ bjNumber[index] }}</td>
<td>{{ njNumber(index) }}</td>
</tr>
</table>
<div>总计:{{ Count }}人</div>
</template>
<script setup>
import { computed } from 'vue'
const nj = [1, 2, 3, 4, 5, 6]
const bjCount = [3, 4, 3, 4, 4, 5]
const bjNumber = [30, 35, 40, 35, 40, 30]
let value
const njNumber = (index) => {
value = computed(() => {
return bjCount[index] * bjNumber[index]
})
}
const Count = () => {
let count = 0
for (let i = 0; i < nj.length; i++) {
njNumber(i)
count += value
}
return count
}
</script>
<style scoped>
table {
margin: 0 auto;
}
td {
border: black solid 1px;
width: 100px;
}
</style>
为啥我的预览结果是这样的,谁能 帮我看下什么问题