element calendar封装样式

效果
请添加图片描述
html:

             <el-calendar v-model="value" id="calendar">
                  <template slot="dateCell" slot-scope="{data }">
                    <div style="position: relative">
                      {{ data.day.split("-").slice(2)[0] }}
                      <div v-for="item in calendarData" :key="item.id"
                        style="width: 100%;position: absolute;top: 0;left: 0;">
                        <div v-if="data.day.split('-').slice(1)[0] == item.months">
                          <div v-if="item.days.indexOf(data.day.split('-').slice(2).join('-')) != -1 && item.type==0"
                            class='li-00'>
                            {{ data.day.split("-").slice(2)[0]}}
                          </div>
                          <div v-if=" item.days.indexOf(data.day.split('-').slice(2).join('-')) !=-1 && item.type==1"
                            class='li-01'>
                            {{ data.day.split("-").slice(2)[0]}}
                          </div>
                        </div>
                        <div v-else></div>
                      </div>
                    </div>
                  </template>
                </el-calendar>

js:

        value: new Date(),
        calendarData: [{
            id: 1,
            months: ["11"],
            days: ["22"],
            type: 0
          }, {
            id: 1,
            months: ["11"],
            days: ["23"],
            type: 0
          }, {
            id: 1,
            months: ["11"],
            days: ["24"],
            type: 0
          }, {
            id: 1,
            months: ["11"],
            days: ["25"],
            type: 0
          },
          {
            id: 2,
            months: ["11"],
            days: ["27"],
            type: 1
          },
          {
            id: 2,
            months: ["11"],
            days: ["28"],
            type: 1
          },
          {
            id: 2,
            months: ["11"],
            days: ["29"],
            type: 1
          }
        ],

css:

  .li-00 {
    background: #2D9B3E !important;
    color: #f1f5fe;
  }

  .li-01 {
    background: #D83E40 !important;
    color: #f1f5fe;
  }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值