Vue自定义日历控件的使用是什么样的呢
Admin 2022-09-01 群英技术资讯 1065 次浏览
这篇文章给大家分享的是“Vue自定义日历控件的使用是什么样的呢”,对大家学习和理解有一定的参考价值和帮助,有这方面学习需要的朋友,接下来就跟随小编一起学习一下吧。本文实例为大家分享了Vue自定义日历小控件的具体代码,供大家参考,具体内容如下
废话少说,先上效果图:

可以在效果图中看到,选择不同的月份的时候当月天数与星期几都是一一对应,非当月天数则是灰色显示,一目了然。
并且此日历控件支持自动确定当前时间,每次打开默认显示的就是最新的月份,用来做签到打卡的功能比较合适。
由于使用的是原生div进行制作,自定义功能非常强,可以自由的更换样式、背景、颜色、大小等等。
在与数据库的时候可以从数据库获得时间信息并填充到控件中,图中的色块就可以看出。
该控件使用了Vue、CSS、以及最原生的div实现了自定义的样式,不得不说,div在自定义这一块是真的太给力了。
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>日历控件</title>
<script src="./vue.js"></script>
</head>
<style>
.writer-upper-right {
float: left;
width: 333px;
height: 300px;
border: 2px orange solid;
border-radius: 7px;
}
.calendar-head {
width: 100%;
height: 15%;
border-radius: 7px;
}
.calendar-body {
width: 99.9%;
height: 84.9%;
border-radius: 7px;
border-top: 1px orange solid;
}
.calendar-head-title {
float: left;
width: 100px;
height: 79%;
line-height: 33px;
border-radius: 7px;
border: 2px orange solid;
margin-top: 2px;
margin-left: 1px;
text-align: center;
color: orange;
font-size: 21px;
}
.calendar-head-year {
float: left;
margin-left: 9px;
width: 100px;
height: 79%;
border-radius: 7px;
border: 2px orange solid;
margin-top: 2px;
color: orange;
text-align: center;
}
.select-calendar-year {
float: left;
width: 100%;
height: 100%;
border: none;
background: none;
color: orange;
text-indent: 0.7em;
font-size: 20px;
}
.select-calendar-year:focus {
outline: none;
}
.select-calendar-year:hover {
cursor: pointer;
}
.calendar-body-week {
width: 99.8%;
height: 32px;
margin: 0 auto;
border-bottom: 1px orange solid;
}
.calendar-body-days {
width: 99.8%;
height: 199px;
border-bottom: 1px orange solid;
border-top: none;
border-radius: 7px;
}
.calendar-body-info {
width: 99.8%;
height: 18px;
border-radius: 7px;
}
.weekEveryDay {
float: left;
width: 40px;
height: 23px;
margin-left: 5px;
margin-top: 4px;
border: 1px orange solid;
border-radius: 5px;
line-height: 23px;
text-align: center;
font-size: 15px;
color: orange;
}
.monthEveryDay {
margin-top: 7px;
}
.not-now-month {
border-color: gray;
color: gray;
}
.now-day-writer {
background-color: orange;
color: black;
}
.now-day-not-writer {
border-color: gray;
background-color: gray;
color: black;
}
.info-if-writer {
float: left;
width: 60px;
height: 16px;
margin-left: 5px;
margin-top: 1px;
}
.color-span {
float: left;
width: 15px;
height: 15px;
margin-top: 1px;
background-color: gray;
}
.color-info {
float: left;
width: 40px;
height: 15px;
margin-top: 1px;
margin-left: 5px;
line-height: 15px;
text-align: left;
font-size: 12px;
color: gray;
}
.color-span2 {
background-color: orange;
}
.color-info2 {
color: orange;
}
</style>
<body style="background: url('./bg-xk.gif');margin: 100px 100px;">
<div id="app">
<div class="writer-upper-right">
<div class="calendar-head">
<div class="calendar-head-title">日历控件</div>
<div class="calendar-head-year">
<label>
<select class="select-calendar-year" v-model="calendarYear" @change="SelectCalendarYear">
<option v-for="year in calendarAllYear" :value="year" :key="year">{{year}}年</option>
</select>
</label>
</div>
<div class="calendar-head-year">
<label>
<select class="select-calendar-year" v-model="calendarMonth" @change="SelectCalendarMonth">
<option v-for="month in calendarAllMonth" :value="month" :key="month">{{month}}月</option>
</select>
</label>
</div>
</div>
<div class="calendar-body">
<div class="calendar-body-week">
<div class="weekEveryDay">SUN</div>
<div class="weekEveryDay">MON</div>
<div class="weekEveryDay">TUE</div>
<div class="weekEveryDay">WED</div>
<div class="weekEveryDay">THU</div>
<div class="weekEveryDay">FRI</div>
<div class="weekEveryDay">SAT</div>
</div>
<div class="calendar-body-days">
<div class="weekEveryDay monthEveryDay not-now-month" v-for="day in calendarPrevDays" disabled>{{day}}</div>
<div class="weekEveryDay monthEveryDay"
v-for="day in calendarNowDays"
:class="['weekEveryDay monthEveryDay', {'now-day-writer' : calendarHadWrite.includes(day)}, {'now-day-not-writer' : calendarNotWrite.includes(day)}]"
>{{day}}</div>
<div class="weekEveryDay monthEveryDay not-now-month" v-for="day in calendarNextDays" disabled>{{day}}</div>
</div>
<div class="calendar-body-info">
<div class="info-if-writer">
<div class="color-span"></div>
<div class="color-info">未更新</div>
</div>
<div class="info-if-writer">
<div class="color-span color-span2"></div>
<div class="color-info color-info2">有更新</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
这篇文章主要介绍了JavaScript执行模型的相关资料。帮助大家更好的理解和学习JavaScript,感兴趣的朋友可以了解下
最近做了一个手机端系统,其中遇到了父页面需要携带参数跳转至子页面的问题,现已解决,下面分享一下实现过程,感兴趣的朋友一起看看吧
TypeScript中命名空间与模块化详情 目录 一.模块 二.命名空间 三.区别 一.模块 TypeScript 与ECMAScript 2015 一样,任何包含顶级 import 或者 export 的文件都被当成一个模块 相反地,如果一个文件不带有顶级的import或者export声明,那么它的内容被视为全局可见的 例如我们在在一个 TypeScript 工程下建立一个文件 1.ts,声明一个变量a,如下: const a = 1 然后在另一个文件同样声明一个变量a,这时候会出现错误信息 提示重复声明a变量,但是所处的空间是全局的
这篇文章主要为大家详细介绍了如何基于Echarts实现绘制立体柱状图的功能,文中的示例代码讲解详细,具有一定的借鉴价值,需要的可以参考一下
本文实例为大家分享了vue开发实现跑马灯效果组件的具体代码,供大家参考,具体内容如下用vue编写一个可以快进后退的跑马灯组件由于业务需求,要实现一个会可以控制速度的跑马灯,初开始用js的setinterval每隔几毫秒来减取一个字符拼接到后面,效果不理想就放弃了。后查询用js的animate这个api改造大功告成!效果
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
7x24小时售前:400-678-4567
7x24小时售后:0668-2555666
24小时QQ客服
群英微信公众号
CNNIC域名投诉举报处理平台
服务电话:010-58813000
服务邮箱:service@cnnic.cn
投诉与建议:0668-2555555
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 ICP核准(ICP备案)粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008