当前位置: 主页 > js >

el-date-picker时间插件,根据月份显示当前月的第一

2020-08-09  |  来源:前端入门建站教程  |  作者:编程之路

下面前端入门建站教程为大家介绍一下el-date-picker时间插件,根据月份显示当前月的第一

//默认根据月份显示当前月的第一天和最后一天
<el-date-picker
            v-model="geMonth"
            type="month"
            placeholder="请选择账期"
            format="yyyy-MM"
            value-format="yyyy-MM"
            @change="getMyDateTime()"
></el-date-picker>

getMyDateTime() {
      const now = new Date(this.geMonth);
      const nowMonth = now.getMonth();
      const nowYear = now.getFullYear();
      const monthStartDate = new Date(nowYear, nowMonth, 1);
      const monthEndDate = new Date(nowYear, nowMonth + 1, 0);
      this.startTime2 = monthStartDate.getFullYear() + '-' + (monthStartDate.getMonth() + 1) + '-' + monthStartDate.getDate()
      this.endTime2 = monthEndDate.getFullYear() + '-' + (monthEndDate.getMonth() + 1) + '-' + monthEndDate.getDate()
    }

上面是“el-date-picker时间插件,根据月份显示当前月的第一”的全面内容,想了解更多关于 js 文章,请继续关注前端入门建站教程。

最新文章

猜你喜欢