Skip to content

Commit 95ee043

Browse files
authored
fix bug
当传入time为null时,前端浏览器渲染报错
1 parent 188ff03 commit 95ee043

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/utils/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
* @returns {string | null}
1010
*/
1111
export function parseTime(time, cFormat) {
12-
if (arguments.length === 0) {
12+
if (arguments.length === 0 && time != null) {
1313
return null
1414
}
1515
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
1616
let date
17-
if (typeof time === 'object' && time != null) {
17+
if (typeof time === 'object') {
1818
date = time
1919
} else {
2020
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {

0 commit comments

Comments
 (0)