
<el-table-column prop="amountRec" :formatter="rbstateFormat" label="金额" min-width="150" ></el-table-column>
methods:{
// 金额千分位
rbstateFormat(row,column,cellValue){
if(cellValue !== null){
cellValue = Number(cellValue).toFixed(2)
cellValue += '';
if (!cellValue.includes('.')) cellValue += '.';
return cellValue.replace(/(\d)(?=(\d{3})+\.)/g, function ($0, $1) {
return $1 + ',';
}).replace(/\.$/, '');
}
},
}
本文介绍了如何使用Element UI的el-table-column进行金额字段的格式化,包括Number对象的toFixed方法和千位分隔符的实现,展示了如何在表格中展示精确到小数点后两位的金额并保持格式一致性。
1825

被折叠的 条评论
为什么被折叠?



