格式化时间函数调用

来源:5-5 -使用Copilot一分钟生成一个formatDate时间格式化函数

一逐星一

2023-08-01

<div class="time">{{ formatDate(blog.updateTime) }}</div>

格式化时间老显示
date.js?t=1690877329898:3 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘getTime’)
at Proxy.formatDate (date.js?t=1690877329898:3:36)
at Proxy._sfc_render (BlogCard.vue:9:28)
at renderComponentRoot (runtime-core.esm-bundler.js:816:16)
at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js:5701:46)
at ReactiveEffect.run (reactivity.esm-bundler.js:178:19)
at instance.update (runtime-core.esm-bundler.js:5814:51)
at setupRenderEffect (runtime-core.esm-bundler.js:5822:5)
at mountComponent (runtime-core.esm-bundler.js:5612:5)
at processComponent (runtime-core.esm-bundler.js:5565:9)
at patch (runtime-core.esm-bundler.js:5040:11)

mock数据用的老师你的

写回答

1回答

双越

2023-08-01

TypeError: Cannot read properties of undefined (reading ‘getTime’)

看,这里有一句很明显的 JS 语法错误,你顺着这个错误先自己排查一下。

0
1
一逐星一
解决了。。没把字符串的日期 转换成时间戳
2023-08-01
共1条回复

程序员的 AI 启蒙课,ChatGPT 辅助开发 Vue3 项目

使用 ChatGPT+Copilot 快速开发仿简书项目,90% 代码由 AI 生成

839 学习 · 30 问题

查看课程