vue(web前段)屬性計算
- 2020 年 3 月 28 日
- 筆記
需求:
在數據列表中,每一條數據的其中一列需要另外兩列相除的值作為這一列的值
增加方法:
compuetedPercentage(res){ res.map((item,index)=>{ item.percentageVal = item.businessAmount / item.entrustAmount * 100 }) },
res是介面返回的數據對象列表
item是每一個數據對象
⚠️percentageVal並不是介面對象的屬性
使用方法:
在請求介面返回數據中增加調用方法 this.compuetedPercentage(response.data)
<el-table-column label="成交進度"> <template slot-scope="scope"> <el-progress :percentage="scope.row.percentageVal"></el-progress> </template> </el-table-column>
完工