效果
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/47dbb574d1f8345133089641e06b13b2.png)
代码
echartsList.value.map((item, i) => {
console.log(item,i,'item i');
const update = Date.parse(item.updateDate.substring(0, 10))
const current = new Date().getTime()
const dayTime = 1000 * 60 * 60 * 24
const sub = current - update
const day = sub / dayTime
if (
moment(current).format('YYYY-MM-DD') ===
moment(item.updateDate).format('YYYY-MM-DD')
) {
item.updateDate = `今天 ${item.updateDate.substring(11).substring(0, 5)}`
} else if (day < 8) {
item.updateDate = Math.ceil(day) - 1 + '天前'
} else {
item
}
return item
})