如何利用element-ui框架中的el-calendar日历组件做一些自定义的修改,比如纪念日之类的,下面编程教程网小编给大家介绍一下代码的使用方法。
代码示例:
<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-calendar日历组件自定义使用方法介绍”的全面内容,想了解更多关于 vuejs 内容,请继续关注编程基础学习网。
编程基础网
本文标题为:el-calendar日历组件自定义使用方法介绍
基础教程推荐
猜你喜欢
- JS中ESModule和commonjs介绍及使用区别 2022-08-30
- Vue自学之路4-vue模版语法(v-clock) 2023-10-08
- Ajax实现城市二级联动(一) 2023-01-31
- JQuery实现左右滚动菜单特效 2024-01-09
- 前端获取http状态码400的返回值实例 2022-11-16
- 重新认识表格和一个访问无障碍的数据表格例子 2022-10-16
- JavaScript中的prototype使用说明 2023-12-27
- 页面图片浮动左右滑动效果的简单实现案例 2024-01-07
- 用ajax传递json到前台中文出现问号乱码问题的解决办法 2023-01-26
- html知识点实践经验总结 2023-12-09
