1.通过毫秒数倒推
const now = new Date();
// - 是向前倒推, + 是向后推
const yesterday = new Date(now.getTime() - 24*60*60*1000);
// 通过减去对应天数的毫秒数来获取日期
2.通过date倒推
// 获取当前时间
const now = new Date();
// - 是向前倒推, + 是向后推
const yesterday = new Date(now.setDate(now.getDate() - 1));
const lastYear = new Date(now.setDate(now.getDate() - 365));
// 通过减去对应的天数来获取日期