精确到指定位数的小数

const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`)

posted @ 2021-08-05 15:59  吴小明-  阅读(35)  评论(0编辑  收藏  举报