vue/前端/js屬性計算

需求:

在數據列表中,每一條數據的其中一列需要另外兩列相除的值作爲這一列的值 

增加方法:

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>

完工

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章