zoukankan      html  css  js  c++  java
  • vue+element设置选择日期最大范围(普通版)

    效果是只能跟当天时间有关(30天),下一篇将来的任意时段,比较符合实际

    <!DOCTYPE html>
    <html>
    <head>
      <meta charset="UTF-8">
      <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    </head>
    <body>
      <div id="app">
        <el-date-picker
          v-model="value"
          type="daterange"
           unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :picker-options="pickerOptions">
        </el-date-picker>
      </div>
    </body>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script>
    new Vue({
        el: '#app',
        data: function() {
          return { 
            value:'',
            pickerOptions: {
              disabledDate(time) {
                let curDate = (new Date()).getTime();  // 当前日期
                let one = 31 * 24 * 3600 * 1000;  //一个月时间
                let oneMonth = curDate - one;  //时间差
                return (time.getTime() > (Date.now()- 8.64e7)) || time.getTime() < oneMonth;  //如果当天可选 就不用减8.64e7
              }
     },
          }
        },
        methods:{
           
        }
    })
    </script>
    </html>
  • 相关阅读:
    面经-新浪
    面经-中兴
    面经-趋势科技
    面经-酷家乐
    面经-大华
    面经-明略科技
    面经-小米
    面经-虹软
    coroutine
    Coroutine 终止协程和异常处理
  • 原文地址:https://www.cnblogs.com/wd163/p/13490420.html
Copyright © 2011-2022 走看看