vue中数字转千分显示
export function numFormat(cellValue) {
cellValue += '';
if (!cellValue.includes('.')) cellValue += '.';
return cellValue.replace(/(\d)(?=(\d{3})+\.)/g, function ($0, $1) {
return $1 + ',';
}).replace(/\.$/, '');
}
页面中使用 使用前先引入方法
el-table 中使用
:formatter="numFormat"
numFormat(row, column, cellValue) {
return numFormat(cellValue)
}
let value = numFormat(params.data.value)