今天就跟大家聊聊有关如何在微信小程序中使用日历组件,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。
创新互联公司专注于企业营销型网站、网站重做改版、阿拉善盟网站定制设计、自适应品牌网站建设、H5开发、商城网站定制开发、集团公司官网建设、外贸营销网站建设、高端网站制作、响应式网页设计等建站业务,价格优惠性价比高,为阿拉善盟等各大城市提供网站开发制作服务。
wxml
减少 增加 {{year}}年 {{currentMonth}}月 {{item}} {{item-(weekNum-1)<=0?"":item-(weekNum-1)>yearMonth[currentMonth-1]?"":item-(weekNum-1)}}
js
// pages/components/calender.js Component({ data:{ weekArr:["日","一","二","三","四","五","六"], yearMonth:[], rowNum:"", dateArr:[], currentMonth:"", year:"", weekNum:"" }, created:function(){}, attached:function(){ let T = new Date() this.setData({ currentMonth: T.getMonth() + 1, year: T.getFullYear() }) //判断闰年 let yeartype = (this.data.year % 4 == 0) && (this.data.year % 100 != 0 || this.data.year % 400 == 0) if ( yeartype ){ this.setData({ yearMonth: [31, 29 , 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] }) }else{ this.setData({ yearMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] }) } let currentMonthDay = this.data.year + "-" + this.data.currentMonth +"-01" let weekStr = "" this.setData({ weekNum: new Date(currentMonthDay).getDay(), rowNum: Math.ceil((this.data.yearMonth[this.data.currentMonth] + new Date(currentMonthDay).getDay())/7) }) for( let i=0 ; iwxss
/* pages/components/calender.wxss */ .operate{ width:100%; display: flex; flex-direction: row; justify-content: space-around; font-size: 32rpx; color:#000; padding-bottom: 40rpx; } .year{ padding:0 30%; display: flex; flex-direction: row; justify-content: space-around; font-size:32rpx; color:#404040; margin-bottom: 40rpx; } .calender{ display: flex; flex-direction: column; padding:0 4.5%; width:91%; border-top:1rpx solid #eaeaea; padding-top:30rpx; color:#404040; } .calender .week{ display: flex; flex-direction: row; } .calender .week text{ width:14%; text-align: center; font-size:26rpx; } .calender .date text{ width:14%; display: inline-block; text-align: center; font-size:26rpx; color:#000; }看完上述内容,你们对如何在微信小程序中使用日历组件有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注创新互联行业资讯频道,感谢大家的支持。
网页标题:如何在微信小程序中使用日历组件
网页链接:http://chengdu.cdxwcx.cn/article/pidiej.html