- 千分符及补0(两位数)
export const setAmountType = (value:any) => {
if (value == 0) {
return '0.00'
} else {
return value ? new Intl.NumberFormat("en", {
minimumFractionDigits: 2,
maximumFractionDigits: 2
}).format(value) : ''
}
}
- 百分号
//转化百分号
export const decimalToPercentage = (decimal, num) => {
if (decimal == undefined || decimal == null) return
// 将小数乘以100并保留两位小数
const percentage = (decimal * num)?.toFixed(2);
// 添加百分号
return percentage + "%";
}