From 6adba9caba6ed60ff096d473c00280b4a4c8b128 Mon Sep 17 00:00:00 2001 From: chenwangji <694093637@qq.com> Date: Wed, 24 Aug 2022 15:02:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20mac,=20ios=20=E7=AB=AF=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=97=A5=E6=9C=9F=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ios里不支持 '-' 连接的日期,会返回 invalid Date,此处统一处理为 `/` --- src/utils/costum.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/costum.js b/src/utils/costum.js index ed5931a..9b5d283 100644 --- a/src/utils/costum.js +++ b/src/utils/costum.js @@ -9,6 +9,10 @@ export function parseTime(time, pattern) { if (typeof time === 'object') { date = time } else { + // 兼容 Mac, ios + if ((typeof time === 'string') && (/-/g.test(time))) { + time = time.replace(/-/g, '/') + } if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) { time = parseInt(time) }