vue2 后端传年月日 时分秒 前端拿到当日时间 做对比 如果是当日的时间 筛选出来

getList () {

this.loading = true

listAlarm(this.queryParams).then(response => {

this.listData = response.rows

const currentDate = new Date()

const year = currentDate.getFullYear()

const month = currentDate.getMonth() + 1 // 月份是从 0 开始计数的,所以需要加 1

const day = currentDate.getDate()

const formattedDate = `{year}-{month < 10 ? '0' + month : month}-${day < 10 ? '0' + day : day}`

console.log('我拿到当前的时间', formattedDate)

let arr = \[\]

// let nowTimeDataList = \[\]

this.listData.forEach(x => {

if (x.createTime.slice(0, 10) == formattedDate) {

arr.push(x.createTime.slice(0, 10))

this.nowTimeDataList.push(x)

}

})

console.log(11111, this.nowTimeDataList)

// this.total = response.total

// this.loading = false

})

},

相关推荐
程序员黑豆1 小时前
鸿蒙应用开发:Refresh + List 下拉刷新组件使用教程
前端·华为·harmonyos
Hilaku1 小时前
为什么大厂对前端算法要求极高?
前端·javascript·程序员
Tkto1 小时前
我用 WebGL 从「画个点」一路画到「贪吃蛇」
前端
xiaobaoyu1 小时前
前端代码常用规范
前端
xiaobaoyu2 小时前
img,word,excel,pdf文件在线预览
前端
lichenyang4532 小时前
从 H5 到 HarmonyOS:我做了一个 npm + OHPM 双端发布的 ArkWeb JSBridge 框架
前端
用户84298142418102 小时前
AI时代,JS混淆加密还有用吗?
前端·javascript
xiaobaoyu2 小时前
如何理解前端项目中的绝对路径和相对路径
前端
xiaobaoyu2 小时前
vue3+vite+vant4项目实战总结
前端
咖啡星人k2 小时前
【无标题】
前端·ai·github