const decimalToPercentFn = (val: number | string, digits = 2) => {
const perVal = Number(val || 0) * 100;
const strPer = perVal.toFixed(digits);
return `${Number(strPer)}%`;
};
const decimalToPercentFn = (val: number | string, digits = 2) => {
const perVal = Number(val || 0) * 100;
const strPer = perVal.toFixed(digits);
return `${Number(strPer)}%`;
};
本文标题:小数转百分比并保留几位小数方法
本文链接:https://www.haomeiwen.com/subject/wkqglrtx.html
网友评论