1.安装moment:

npm install moment --save

2.引入:

import moment from 'moment'

3.在js模块中使用:

 // 今日
    today() {
      var date = moment(new Date()).format('YYYY-MM-DD')
      var today = moment().subtract('days', 0).format('YYYY-MM-DD')
      this.advertOrderStatisSearch.startDate = date
      this.advertOrderStatisSearch.endDate = date
      this.getAdvertOrderData()
    },
    // 昨天
    yesterday() {
      var date = moment(new Date().getTime() - 3600 * 24 * 1000).format('YYYY-MM-DD')
      var date2 = moment().subtract('days', 1).format('YYYY-MM-DD')
      this.advertOrderStatisSearch.startDate = date
      this.advertOrderStatisSearch.endDate = date
      this.getAdvertOrderData()
    },
    // 最近七天
    lastSevenDays() {
      var startDate = moment(new Date().getTime() - 3600 * 24 * 1000 * 6).format('YYYY-MM-DD')
      var todayDate = moment(new Date()).format('YYYY-MM-DD')
      var startDate2 = moment().subtract('days', 6).format('YYYY-MM-DD')
      this.advertOrderStatisSearch.startDate = startDate
      this.advertOrderStatisSearch.endDate = todayDate
      this.getAdvertOrderData()
    },
    // 本月
    month() {
      const startDate = moment().subtract('month', 0).format('YYYY-MM') + '-01'
      const endDate = moment(new Date()).format('YYYY-MM-DD')
      this.advertOrderStatisSearch.startDate = startDate
      this.advertOrderStatisSearch.endDate = endDate
      this.getAdvertOrderData()
    },

 

Logo

前往低代码交流专区

更多推荐