Przeglądaj źródła

兼容:参数不对返回空

lifanagju_citu 10 miesięcy temu
rodzic
commit
52ffc9c181
1 zmienionych plików z 2 dodań i 0 usunięć
  1. 2 0
      src/utils/date.js

+ 2 - 0
src/utils/date.js

@@ -1,5 +1,6 @@
 // 时间戳转换为年月日时分秒
 export const timesTampChange = (timestamp) => {
+  if (!timestamp) return ''
   const date = new Date(timestamp)
   const Y = date.getFullYear() + '-'
   const M = (date.getMonth() + 1).toString().padStart(2, '0') + '-'
@@ -14,6 +15,7 @@ export const timesTampChange = (timestamp) => {
 
 // 将 Wed May 01 2024 00:00:00 GMT+0800 (中国标准时间) 转换为时间戳
 export const getTimeStamp = (str) => {
+  if (!str) return ''
   const date = new Date(str)
   return date.getTime()
 }