怎么判断时间是不是在2天前

     canEdit () {
        if (!this.visitLog || !this.visitLog.visitTime) return false
        let twoDaysAgo = new Date().setHours(0, 0, 0, 0) - 2 * 24 * 3600 * 1000
        return new Date(this.visitLog.visitTime.replace(/-/g, '/')).getTime() > twoDaysAgo
      },

new Date().setHours(0, 0, 0, 0) 表示的是零点的时间戳

原文地址:https://www.cnblogs.com/antyhouse/p/11041270.html