拿到当前时间和当前时间往前推一个月的字符串.可用在elementui时间组件上

let year = new Date().getFullYear()
    let month = new Date().getMonth()
    let currentMonth = new Date().getMonth() + 1
    let day = new Date().getDate()
    if (month >= 1 && month <= 9) {
      month = '0' + month
      currentMonth = '0' + currentMonth
    }
    if (day && day <= 9) {
      day = '0' + day
    }
    let str = year + '-' + month + '-' + day
    let str1 = year + '-' + currentMonth + '-' + day
    this.fzTime[0] = str
    this.fzTime[1] = str1

 

posted on 2021-09-07 16:45  荻!!!!!!!!  阅读(244)  评论(0编辑  收藏  举报