美文网首页
el-date-picker禁用之后或之前日期

el-date-picker禁用之后或之前日期

作者: 明天_8c66 | 来源:发表于2021-09-15 10:52 被阅读0次
    <!DOCTYPE html>
    <html>
    
    <head>
      <meta charset="UTF-8">
      <!-- import CSS -->
      <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
      <link rel="stylesheet" href="./t.css">
    </head>
    
    <body>
      <div id="app">
        <template>
          <el-date-picker v-model="buildDate" :picker-options="pickerOptions" type="date" style="width: 90%"
            value-format="yyyy-MM-dd" placeholder="选择日期" />
        </template>
      </div>
    </body>
    <!-- import Vue before Element -->
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <!-- import JavaScript -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script src="https://cdn.bootcss.com/moment.js/2.20.1/moment.min.js"></script>
    <script src="https://cdn.bootcss.com/moment.js/2.20.1/locale/zh-cn.js"></script>
    <script>
    
      new Vue({
        el: '#app',
        data() {
          return {
            buildDate: '',
            pickerOptions: {
              disabledDate(time) { }
            }
          }
        },
        created() {
          this.pickerOptions.disabledDate = (time) => {
            console.log(time);
            // console.log(moment(date, 'YYYY-MM-DD').endOf('month').format('YYYY-MM-DD'), 'this.assetOpenTime')
            const now = moment(time).format('YYYY-MM-DD')
            // const bookStart = moment(date).format('YYYY-MM')
            const bookStart = moment(new Date()).format('YYYY-MM-DD')
            return now > bookStart
          }
        },
        methods: {
    
        }
    
      })
    </script>
    
    </html>
    

    相关文章

      网友评论

          本文标题:el-date-picker禁用之后或之前日期

          本文链接:https://www.haomeiwen.com/subject/jylrgltx.html