栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

Vue.js创建Calendar日历效果

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Vue.js创建Calendar日历效果

使用 Vue.js 进行数据与视图的绑定,数据更新会让视图自动进行更新,类似 Android 里面的 DataBinding。
实现一个HTML的日历效果。

html 部分


 
 
 
  • {{ currentYear }} {{ currentMonth }}月
  • {{ day.getDate() }} {{ day.getDate() }} {{ day.getDate() }}

id 为 calendar 对应的创建一个 Vue 对象,设置 el 为 ‘#calendar'。


完整代码:



 
 
 日历
 
 * {
 box-sizing: border-box;
 }
 
 ul {
 list-style-type: none;
 }
 
 body {
 font-family: Verdana, sans-serif;
 background: #E8F0F3;
 }
 #calendar{
 width:80%;
 margin: 0 auto;
 box-shadow: 0 2px 2px 0 rgba(0,0,0,0.14), 0 3px 1px -2px rgba(0,0,0,0.1), 0 1px 5px 0 rgba(0,0,0,0.12);
 }
 .month {
 width: 100%;
 background: #00B8EC;
 }
 
 .month ul {
 margin: 0;
 padding: 0;
 display: flex;
 justify-content: space-between;
 }
 
 .year-month {
 display: flex;
 flex-direction: column;
 align-items: center;
 justify-content: space-around;
 }
 
 .year-month:hover {
 background: rgba(150, 2, 12, 0.1);
 }
 
 .choose-year {
 padding-left: 20px;
 padding-right: 20px;
 }
 
 .choose-month {
 text-align: center;
 font-size: 1.5rem;
 }
 
 .arrow {
 padding: 30px;
 }
 
 .arrow:hover {
 background: rgba(100, 2, 12, 0.1);
 }
 
 .month ul li {
 color: white;
 font-size: 20px;
 text-transform: uppercase;
 letter-spacing: 3px;
 }
 
 .weekdays {
 margin: 0;
 padding: 10px 0;
 background-color: #00B8EC;
 display: flex;
 flex-wrap: wrap;
 color: #FFFFFF;
 justify-content: space-around;
 }
 
 .weekdays li {
 display: inline-block;
 width: 13.6%;
 text-align: center;
 }
 
 .days {
 padding: 0;
 background: #FFFFFF;
 margin: 0;
 display: flex;
 flex-wrap: wrap;
 justify-content: space-around;
 }
 
 .days li {
 list-style-type: none;
 display: inline-block;
 width: 14.2%;
 text-align: center;
 padding-bottom: 15px;
 padding-top: 15px;
 font-size: 1rem;
 color: #000;
 }
 
 .days li .active {
 padding: 6px 10px;
 border-radius: 50%;
 background: #00B8EC;
 color: #fff;
 }
 
 .days li .other-month {
 padding: 5px;
 color: gainsboro;
 }
 
 .days li:hover {
 background: #e1e1e1;
 }
 
 
 
 CSS 日历
 
 
 
  • {{ currentYear }} {{ currentMonth }}月
  • {{ day.getDate() }} {{ day.getDate() }} {{ day.getDate() }}

本文已被整理到了《Vue.js前端组件学习教程》,欢迎大家学习阅读。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/93025.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号