element-plus的el-calendar日历组件使用#date-cell插槽踩坑不生效

使用elementplus的时候发现#date-cell不生效,插槽没有被检测到

 解决方法:这时候只需要将#date-cell改成#dateCell就可以了,修改之后插槽就能用了。

 代码:

<el-calendar ref="calendar" class="aaa">
          <template #header="{ date }">
            <el-button-group>
              <el-button size="small" @click="selectDate('prev-month')">
                <el-icon><CaretLeft /></el-icon>
              </el-button>
            </el-button-group>
            <span>{{ date }}</span>
            <el-button-group>
              <el-button size="small" @click="selectDate('next-month')">
                <el-icon><CaretRight /></el-icon>
              </el-button>
            </el-button-group>
          </template>
          <template #dateCell="{ data }">
            <div @click="clickDay(data)">
              <el-row>
                <el-col class="datastyle">
                  {{ data.day.split("-").slice(2).join("-") }}</el-col
                >
              </el-row>
              <e-row>
                <el-col class="center">
                  <el-tag type="warning" class="tag">
                    <el-row>
                      <el-col :span="17" class="tag">
                        <span>当日限约</span>
                      </el-col>
                      <el-col :span="1"></el-col>
                      <el-col :span="6" class="tag2">
                        <span>500</span>
                      </el-col>
                    </el-row>
                  </el-tag>
                </el-col>
              </e-row>
              <el-row style="margin-top: 10px" class="yuyue">
                <el-col :span="11" class="center">
                  <span>已约</span
                  ><span class="center2" style="">10</span></el-col
                >
                <el-col :span="2" class="center">|</el-col>
                <el-col :span="11" class="center">
                  <span>剩余</span><span class="center2">0</span></el-col
                >
              </el-row>
            </div>
          </template>

 css:

<style scoped>
/deep/.el-calendar__body {
  padding: 4px 20px 35px;
}
/deep/ .el-calendar-table thead th {
  color: #ffab11;
  font-weight: bold;
  font-size: 25px;
}
.tag {
  display: flex;
  align-items: center;
  height: 2.5vh;
  justify-content: center;
}
.tag2 {
  display: flex;
  align-items: center;
  height: 2.5vh;
  justify-content: center;
  font-size: 18px;
}
.aaa .is-selected .yuyue {
  color: #ffab11;
}
.aaa .datastyle {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 3rem;
  color: #353636;
  font-weight: 600;
}
/deep/.el-calendar-table .el-calendar-day:hover {
  background-color: #faecd8;
}
/deep/.el-calendar {
  --el-calendar-selected-bg-color: #faecd8;
}
.aaa .is-selected .datastyle {
  color: #ffab11;
}
.aaa .prev .datastyle {
  color: #c4c5c8;
}
.aaa .next .datastyle {
  color: #c4c5c8;
}
/deep/.el-calendar {
  --el-calendar-cell-width: 130px;
}
.center {
  display: flex;
  justify-content: center;
  align-items: center;
}
.center2 {
  display: flex;
  justify-content: center;
  align-items: center;
  color: #ffab11;
  margin-left: 5px;
  font-size: 20px;
}
/deep/.el-calendar__header {
  justify-content: center;
}

效果图:

 

  • 9
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值