From 6610549a0032e79c283825c8134f6857362d932f Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Mon, 1 Jun 2020 13:25:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=20formatMoney=20=E5=92=8C=20?= =?UTF-8?q?formatPercent=20=E5=88=B0=20unify?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.js b/index.js index a1cf375..3d68342 100644 --- a/index.js +++ b/index.js @@ -93,6 +93,14 @@ module.exports = { } }, + formatMoney(value, decimal){ + return Number(value).toFixed(decimal||2) + }, + + formatPercent(value, decimal){ + return `${Number(value*100).toFixed(decimal||2)}%` + }, + formatDate(date, format){ if (!(date instanceof Date)){ date = new Date(date)