码迷,mamicode.com
首页 > 其他好文 > 详细

iview DatePicker 只能选本月

时间:2019-11-02 13:45:06      阅读:303      评论:0      收藏:0      [点我收藏+]

标签:hang   eof   时间   first   ram   mat   date()   eve   ble   

html

<FormItem label="活动时间" prop="activity_time">
                    <DatePicker
                      v-model="addForm.activity_time"
                      @on-change="param.activity_time=$event"
                      type="date"
                      format="yyyy-MM-dd"
                      :options="options"
                      placeholder="活动时间"
                      style="width: 214px"
                      :disabled="modalDisable"
                    ></DatePicker>
                  </FormItem>

 

js

options: {
        disabledDate(date) {
          let dateTime = new Date();
          let currentYear = dateTime.getFullYear();
          let currentMonth = dateTime.getMonth();
          let monthFirstDay = new Date(currentYear, currentMonth, 1);

          let newMonth = ++currentMonth;
          let newYear = currentYear;
          if (newMonth >= 12) {
            newMonth -= 12;
            newYear++;
          }
          let nextMonthFirst = new Date(newYear, newMonth, 1);
          let nonthLastDay = new Date(
            nextMonthFirst.getTime() - 24 * 60 * 60 * 1000
          );
          return (
            date.valueOf() < new Date(monthFirstDay).getTime() ||
            date.valueOf() > new Date(nonthLastDay).getTime()
          );
        }
      } //时间范围限制

 

iview DatePicker 只能选本月

标签:hang   eof   时间   first   ram   mat   date()   eve   ble   

原文地址:https://www.cnblogs.com/mxyr/p/11781323.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!