HTML相关代码
<el-table border :data="tableDatas" highlight-current-row v-loading="isLoading" style="width: 100%">
<el-table-column align="center" prop="total" label="激活码体验总数量"></el-table-column>
<el-table-column v-for="(col,index) in cols" :key="index" :prop="`num${index + 1}`" :label="`${col.dayTime}天卡`"> </el-table-column>
</el-table>
JS相关代码
getActivationCodeExperienceData(send).then(res => {
this.isLoadings = false
if (res.data.status === 0) {
// [{dayTime: 7, num: 2},{dayTime: 7, num: 2}]
this.cols = res.data.data
this.tableDatas = []
const tempObj = {
total: 0
}
this.cols.map((val, index) => {
tempObj[`num${index + 1}`] = val.num
tempObj.total += +val.num
})
this.tableDatas.push(tempObj)
}
}).catch(() => {
this.isLoadings = false
})