web建站教程
  1. 首页
  2. vuejs
  3. js
  4. 好玩
  5. AIGC工具
  6. 前端知识
  7. 百度echarts
  8. 更多
    php入门
    nodejs
    mockjs
    reactjs
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站
    手机应用

el-calendar日历组件自定义使用方法介绍

1199 ℃

如何利用element-ui框架中的el-calendar日历组件做一些自定义的修改,比如纪念日之类的,下面web建站小编给大家介绍一下代码的使用方法。

代码示例:

<el-calendar v-model="value" id="calendar">
  <!-- 这里使用的是 2.5 slot 语法,对于新项目请使用 2.6 slot 语法-->
  <template
   slot="dateCell"
   slot-scope="{date, data}">
    <!--自定义内容-->
    <div>
      <div class="calendar-day">{{ data.day.split('-').slice(2).join('-') }}</div>
         <div v-for="item in calendarData">
           <div v-if="(item.months).indexOf(data.day.split('-').slice(1)[0])!=-1">
             <div v-if="(item.days).indexOf(data.day.split('-').slice(2).join('-'))!=-1">
               <el-tooltip class="item" effect="dark" :content="item.things" placement="right">
                  <div class="is-selected">{{item.things}}</div>
               </el-tooltip>
             </div>
            <div v-else></div>
           </div>
        <div v-else></div>
      </div>
    </div>
  </template>
</el-calendar>
 
<script>
  export default {
    name: "calendar",
    data(){
      return {
        calendarData: [
          { months: ['09', '11'],days: ['15'],things: '看电影' },
          { months: ['10', '11'], days: ['02'],things: '去公园野炊' },
          { months: ['11'], days: ['02'],things: '看星星' },
          { months: ['11'], days: ['02'],things: '看月亮' }   
        ],
        value: new Date()
      }
    }
  }
</script>
<style>
  .calendar-day{
      text-align: center;
      color: #202535;
      line-height: 30px;
      font-size: 12px;
  }
  .is-selected{
      color: #F8A535;
      font-size: 10px;
      margin-top: 5px;
  }
  #calendar .el-button-group>.el-button:not(:first-child):not(:last-child):after{
      content: '当月';
  }
</style>

el-time-picker设置默认赋值时间

Vue项目如何实现文件上传(附完整代码)

Vue开发中最常用的几种UI组件库

vue语法如何设置el-select默认值

el-tree组件如何添加虚线指示

标签: el-calendar, element-ui, 日历组件

上面是“el-calendar日历组件自定义使用方法介绍”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_2461.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 网站首页 > vuejs
本文共计1208个字,预计阅读时长9分钟
Trae:新一代免费的AI编程工具

基金从业资格考试题库

一站式备考基金从业资格考试,收录2021-2025年模拟题库!呱呱工具箱

AI工作站

收录全球3800+ 款各行各业AI应用,轻轻松松做事!
生活小工具,收录了80多款小工具
上一篇: 程序员正能量文案:乐观积极的治愈系文案,朋友圈满满向上动力句子
下一篇: Lunar组件如何利用I18n实现多语言功能
x 打工人ai神器