From f1389237600bbea13836b1b12317dcd35fbd4e3d Mon Sep 17 00:00:00 2001 From: cai-peiyuan <37100059+cai-peiyuan@users.noreply.github.com> Date: Fri, 6 Dec 2019 17:15:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=97=B6=E9=97=B4=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=E6=96=B9=E6=B3=95=E5=8F=82=E6=95=B0=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E6=83=85=E5=86=B5=20(#53)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 判断时间格式化方法参数为空情况 --- src/utils/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/index.js b/src/utils/index.js index 71bce1c..ab7ad30 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -14,7 +14,9 @@ export function parseTime(time, cFormat) { } const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}' let date - if (typeof time === 'object') { + if (typeof time === 'undefined' || time === null || time === 'null') { + return '' + } else if (typeof time === 'object') { date = time } else { if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { @@ -384,4 +386,3 @@ export function downloadFile(obj, name, suffix) { link.click() document.body.removeChild(link) } -