c语言codeblock简单日历,vue实现简单日历
1
2
3
4
5
6
日历
7
8 * {
9 padding: 0;
10 margin: 0;
11 }
12
13 ul {
14 list-style-type: none;
15 }
16
17 #calendar {
18 width: 450px;
19 height: 300px;
20 margin: 100px auto;
21 border-radius: 2px;
22 box-shadow: 0 2px 1px -1px rgba(0, 0, 0, 0.2), 0 1px 1px 0 rgba(0, 0, 0, 0.14),
23 0 1px 3px 0 rgba(0, 0, 0, 0.12);
24 }
25
26 .title {
27 font-size: 20px;
28 letter-spacing: 3px;
29 display: flex;
30 justify-content: space-between;
31 background-color: #ed8079;
32 color: #ffffff;
33 }
34
35 .title .arrow {
36 padding: 20px;
37 cursor: pointer;
38 }
39
40 .year-month {
41 display: flex;
42 flex-direction: column;
43 align-items: center;
44 justify-content: space-around;
45 }
46
47 .weekdays {
48 margin: 0;
49 padding: 10px 0;
50 display: flex;
51 flex-wrap: wrap;
52 justify-content: space-around;
53 }
54
55 .weekdays li {
56 display: inline-block;
57 width: 13.6%;
58 text-align: center;
59 }
60
61 .days {
62 padding: 0;
63 background: #ffffff;
64 margin: 0;
65 display: flex;
66 flex-wrap: wrap;
67 justify-content: space-around;
68 }
69
70 .days li {
71 display: inline-block;
72 width: 14.2%;
73 text-align: center;
74 padding-bottom: 8px;
75 padding-top: 8px;
76 }
77
78 .days li .active {
79 padding: 4px 10px;
80 border-radius: 50%;
81 background: #ed8079;
82 color: #fff;
83 }
84
85 .days li .other {
86 padding: 5px;
87 color: gainsboro;
88 }
89
90 .days li:hover {
91 background: #e1e1e1;
92 }
93
94
95
96
97
98
99
100
101 @click="changeMonth('pre')"
102 > ❮
103
104 {{currentYear}}年{{currentMonth}}月
105
106
107
108 @click="changeMonth('next')"
109 > ❯
110
111
112
113
114 v-for='(val,key) in weeks'
115 >
116
117 {{val}}
118
119
120
121
122
123
124
125
126 v-for='(val,key) in days'
127 >
128
129 :class='chooseClass(val.day)'
130 >
131 {{val.day.getDate()}}
132
133
134
135
136
137 new Vue({
138 el: "#calendar",
139 data: {
140 currentDay: 1,
141 currentMonth: 1,
142 currentYear: 1970,
143 currentWeek: 1,
144 weeks: ["一", "二", "三", "四", "五", "六", "日"],
145 days: []
146 },
147 created() {
148 this.init();
149 },
150 methods: {
151 init(data) {
152 let day;
153
154 if (data) {
155 day = new Date(data);
156 } else {
157 let now = new Date();
158 day = new Date(this.formDate(now.getFullYear(), now.getMonth() + 1, 1));
159 }
160
161 this.currentDay = day.getDate();
162 this.currentYear = day.getFullYear();
163 this.currentMonth = day.getMonth() + 1;
164
165 this.currentWeek = day.getDay();
166
167 if (!this.currentWeek) {
168 this.currentWeek = 7;
169 }
170
171 this.days.length = 0;
172 let str = this.formDate(
173 this.currentYear,
174 this.currentMonth,
175 this.currentDay
176 );
177
178 for (let i = 2 - this.currentWeek ; i < 37 - this.currentWeek; i++) {
179 let d = new Date(str);
180 d.setDate(i);
181 this.days.push({
182 day: d
183 });
184 }
185
186 // //获取上月末至本月第一天的日期
187 // for (let i = this.currentWeek - 1; i >= 0; i--) {
188 // let d = new Date(str);
189 // d.setDate(d.getDate() - i);
190 // this.days.push({
191 // day: d
192 // });
193 // }
194
195 // //获取剩余的日期
196 // for (let i = 1; i <= 35 - this.currentWeek; i++) {
197 // let d = new Date(str);
198 // d.setDate(d.getDate() + i);
199 // this.days.push({
200 // day: d
201 // });
202 // }
203 },
204
205 //其他月加class名'other',今天加class名'active'
206 chooseClass(day) {
207 if (day.getMonth() + 1 != this.currentMonth) return "other";
208
209 let a = new Date() - day;
210 if (a > 0 && a < 86400000) return "active";
211 },
212 //改变周六日显示颜色
213 chooseStyle(key) {
214 if (key === 5 || key === 6) return "color:#f1aaab";
215 },
216 //切换月份
217 changeMonth(a) {
218 let d = new Date(this.formDate(this.currentYear, this.currentMonth, 1));
219
220 // setDate(0); 上月最后一天
221 // setDate(-1); 上月倒数第二天
222 // setDate(n) 参数n为 上月最后一天的前后n天
223 a === "pre" ? d.setDate(0) : d.setDate(35);
224
225 this.init(this.formDate(d.getFullYear(), d.getMonth() + 1, 1));
226 },
227 //返回字符串个格式的日期
228 formDate(year, month, day) {
229 return year + "-" + month + "-" + day;
230 }
231 }
232 });
233
234
238
标签:flex,vue,日历,days,padding,let,简单,new,day
来源: https://www.cnblogs.com/theblogs/p/10367361.html
c语言codeblock简单日历,vue实现简单日历相关推荐
- 利用html写一个日历,Vue写一个日历
基础回顾 关于 Date API getFulleYear(); // 年 getMonth(); // 月, 0-11 getDate(); // 日,也就是几号 getDay(); // 星期几, ...
- 简单实现Vue中的虚拟dom
简单实现Vue中的虚拟dom 传送门:简单实现Vue中的插值替换(三) 前言: 要想简单实现虚拟dom,首先我们要了解虚拟dom,知道自己要实现的是个什么东西. 说起来,我刚开始学习Vue的时候对虚拟 ...
- 用php做一个简单的汇率,vue实现简单实时汇率计算功能
最近在自己摸索vue的使用,因为相对于只是去看教程和实例,感觉不如自己动手写一个demo入门来的快.刚好看到小程序中有一个简单但是很精致的应用极简汇率,而且它的表现形式和vue的表现形式很像,于是想着 ...
- C语言读取bmp图像并做简单显示
C语言读取bmp图像并做简单显示) bmp文件格式 读取bmp文件信息并展示 bmp文件格式 bmp文件大体上分为四个部分: bmp文件构成 位图文件头BITMAPFILEHEADER 位图信息头BI ...
- react构建淘票票webapp,及react与vue的简单比较。
前言 前段时间使用vue2.0构建了淘票票页面,并写了一篇相关文章vue2.0构建淘票票webapp,得到了很多童鞋的支持,因此这些天又使用react重构了下这个项目,目的无他,只为了学习和共同进步! ...
- 前端app调起摄像头 只显示在页面_猫也能看得懂的教程之一分钟使用Vue搭建简单Web页面...
本教程适合人群: 已经了解过过html.js.css,想深入学习前端技术的小伙伴 有前端开发经验.但是没有使用过Vue的小伙伴 有过其他编程经验,对前端开发感兴趣的小伙伴 学习本教程之后你将会: 了解 ...
- vue实现简单表格组件
本来想这一周做一个关于vuex的总结的,但是由于朋友反应说还不知道如何用vue去写一个组件,所以在此写写一篇文章来说明下如何去写vue页面或者组件.vue的核心思想就是组件,什么是组件呢?按照我的理解 ...
- 用C语言编写一个Linux下的简单shell程序
这是一个简单的C程序,展示了如何进行系统调用执行logout cd ls pwd pid rm mkdir mv cp等命令,这是一个简单的命令解释程序shell,其源代码如下: #include & ...
- 基于vue-cli、elementUI的Vue超简单入门小例子
基于vue-cli.elementUI的Vue超简单入门小例子 这个例子还是比较简单的,独立完成后,能大概知道vue是干嘛的,可以写个todoList的小例子. 开始写例子之前,先对环境的部署做点简单 ...
最新文章
- Oracle Schema Objects——Index
- python小项目实例流程-python——房价预测案例(完整项目流程)
- 【干货】为什么都跑去用HTTPS了?
- 怎么关闭默认使用腾讯视频播放视频文件
- 启动之后自己关闭_电脑怎么关闭自动更新
- django-模板的母版与子版
- sublime text3 快速生成方法注释
- linux内核镜像的分层,Docker 入门教程:镜像分层
- VS2012+ArcGIS Engine10.2安装教程
- WordPress后台定制-为WooCommerce产品增加自定义字段
- 【笔记】用Python写百度翻译网络爬虫
- 如何在亿级数据中判断一个元素是否存在?
- leetcode No5 最长回文子串
- deflate 压缩 java_Java和PHP配合:deflate(压缩)和inflate(解压)
- VMware vSphere Client 安装虚拟机
- rk3399 typec鼠标及滑鼠问题
- 各种字符编码与Char字符
- android 和 js 之间交互的封装
- cad用键盘放大缩小_cad放大的命令多少(CAD的放大缩小快捷键是什么?)
- 二进制安装k8s集群V1.23.0
热门文章
- oppo服务器是网络运营商的吗,OPPO的无网络通信技术到底是什么?
- 图片如何缩小?缩小图片的教程介绍
- Docker win10家庭版安装
- 利用爬虫下载番剧进行追番
- Buildroot_5.10 rk809音频(实现 耳机+喇叭 切换)+ HDMI音频 + 视频播放测试指令(4K)
- Android Studio调试工具总结
- IOS(IPHONE)手机简单快捷导入联系方式
- 逆战用计算机咋弹,逆战烟雾弹怎么用_逆战如何利用好烟雾弹_快吧游戏
- E013 如何把Excel表格数据写入Ppt文本框内
- Stata实操陷阱:动态面板数据模型