好看实用的日历插件

我在工作中,前端老大哥给了我个需求,让我完成个样式精美的日历,并且确定每天打卡情况,然后完成之后说是日历太丑了,我然后我去网上找了找好看的,,最后在b站上看到一个,样式确实不错,这位up主将代码开源了, https://github.com/CiroLee/html_css_javascript,感兴趣的可以去看看

这个日历确实包含寻常日历功能,然后我加了个打卡的功能,也算减少了一点工作量

这里为了方便我用了dayjs方便

function getRecord(date = new Date(), create = false) { console.log('vm.userinfo.userid', vm.userinfo.userid); let list = []; let searchMonth = dayjs(date).format('YYYY-MM') console.log('searchMonth', searchMonth); $.ajax({ type: 'GET',
   // 这个地址是根据当月来确定 url: `https:
//m.jxmf.com.cn/v3/index.php?c=App_Xxlj&m=calendarList&userid=${vm.userinfo.userid}&month=` + searchMonth, dataType: 'json', // jsonpCallback:'callback', timeout: 10000, context: $('body'), success: function (res) { console.log('calendaar_resmonthList', res) res.data.map((item, index) => { list.push(item.wekday) }) console.log(list) let calendarDate = $('.date-num') for (var i = 0; i < calendarDate.length; i++) { calendarDate[i].classList.remove('signIn') for (var j = 0; j < list.length; j++) { let date2 = $(calendarDate[i]).attr('date') let month = dayjs(date2).format('MM') let day = dayjs(date2).format('DD') if (day == list[j].substr(6, 2)) { // console.log(document.getElementById('title2').innerText.substr(6, 2) - 1); calendarDate[i].classList.add('signIn') console.log(document.getElementById('title2').innerText.substring(5, 7)); if (month != list[j].substr(4, 2)) { calendarDate[i].classList.remove('signIn') } } } } }, error: function (xhr, type) { console.log('Ajax error!') } }); renderCalendar(date, create); console.log(date); }
用的时候挂载后 使用即可,如果是需要判断不同的人打卡情况,获取用户信息的时候加上 getRecord(date = new Date(), true) 即可

上面的  calendarDate[i].classList.add('signIn') 就是这个选中的样式了,

至于加什么样式,需要什么样式就看自己的需求了

最后,确实感谢这位b站的up主


__EOF__

本文作者h_h123
本文链接https://www.cnblogs.com/huangjunhua/p/16608636.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   h_h123  阅读(563)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
点击右上角即可分享
微信分享提示