Bootstrap

vue 获取一个月时间方法

代码

data(){
 return{
    searchForm:{dateTime:[]}
 }
}

js 方法代码

// 获取当前时间
    getMouthTime() {
      let nowDate = new Date();
      let date = {
        year: nowDate.getFullYear(),
        month: nowDate.getMonth() + 1,
        date: nowDate.getDate(),
      };
      // 当前日期
      let systemDate = date.year + "-" + date.month + "-" + date.date;
      let beforedate = new Date(nowDate);
      beforedate.setDate(nowDate.getDate() - 30);
      // 30天前
      let systemDateBegin = `${beforedate.getFullYear()}-${beforedate.getMonth() + 1 < 10 ? `0${beforedate.getMonth() + 1}` : beforedate.getMonth() + 1}-${beforedate.getDate()}`;
      this.searchForm.dateTime = [systemDateBegin, systemDate]
    },

;