Antd 中的 table 组件中对金额值的字段 ,进行千分位的分割,并保留俩位小数。
效果图:
代码:
//千分位校验
const moneyFormat = (num) => {
return (Number(num).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1,'))
}
const columns = [
{
title: '投融资原值',
dataIndex: 'money',
width: 150,
align: 'right',
onCell:() => {
return {
style:{
maxWidth:100,
overflow:'hidden',
whiteSpace:'nowrap',
textOverflow:'ellipsis',
cursor:'pointer'
}
}
},
render: (item) => (
<Tooltip placement="topLeft" title={moneyFormat(item)}>
{moneyFormat(item)}
</Tooltip>)
},
]