soonfy / issue-blog

blog using issue
0 stars 0 forks source link

js 小数百分比转换 #16

Open soonfy opened 6 years ago

soonfy commented 6 years ago

小数转百分比

const toPercent = (point) => {
    let percent = Number(point * 100).toFixed(2);
    percent += '%';
    return percent;
}

百分比转小数

const toPoint = (percent) => {
    let point = percent.replace('%', '');
    point = point / 100 - 0;
    return point;
}

soonfy