/* JS代码部分*/3 const Date=new Date()const years=[]const months=[]const days=[]const hours=[]const分钟=[]var thisMon=Date。getmonths();var this day=date。getdate();用于(让i=2017I=日期。get full year()1;i ) { years.push(i)}for(让I=日期。getmonth();I=11I){ var k=I;if(0=I I 9){ k=' 0 '(I 1);} else { k=(I ^ 1);}个月。push(k)} if(0=这个mon这个mon 9){这个mon=' 0 '(这个mon 1);} else { this mon=(this mon 1);} if(0=本日本日10){本日=' 0 '本日;} var total day=mGetDate(date。getfullyear()、本周一);用于(设I=1;I=31I){ var k=I;if(0=I I 10){ k=' 0 ' I }天。push(k)} for(让I=0;I=23I){ var k=I;if(0=I I 10){ k=' 0 ' I }小时。push(k)} for(让I=0;I=59I){ var k=I;if (0=i i 10) { k='0' i }分钟。push(k)}函数mGetDate(年,月){ var d=新日期(年,月,0);返回d . GetDate();}Page({ data: { years:year: date.getFullYear(),month : month : this mon,days: days,day: thisDay,value: [1,thisMon - 1,thisDay - 1,0,0],hours: hours,hour: ' 00 ',minutes: minutes,minutes 3: ' 00 ' },bind var change date=}用于(设I=1;I=total dayi){ var k=I;if(0=I I 10){ k=' 0 ' I }更改日期。推(k)这个。setdata({ days : change date })},})/* css代码部分*/.时间标题{ float:left宽度:20%;文本对齐:居中;color: # 45BCE8}。picker-text { text-align : center;}/*屏蔽*/。time _ screens { width : 100%;位置:固定;底部: 0;左: 0;z指数: 1000;opacity: 0.5飞越:隐藏;}/* html代码部分*/view class=' time _ screens ' view style=' text-align : center;color : # 45bce 8 "年}}-{ {月} }-{ {日} }标签样式=' float:left边距-左侧:30像素;取消/label label style=' float : right;'右边距:30 px'确定/label/view view style=' border-top :1 px solid # 45BCE 8;height :25 px ' font-size :14 px;'/view picker-view指示器-style=' height : 50px;'style=' width : 100%;'height : 300 px ' value=' { { value } } ' bind change=' bind change ' picker-view-column class=' picker-text ' view wx : for=' { { years } } ' style=' line-height : 50px ' { item } }年/view/picker-view-column picker-view-column class=' picker-text ' view wx : for=' { { months } } ' style='行高: 50px ' { item } }月/view/picker-view-column picker-view-column class=' picker-text ' view wx : for=' { { days } } ' style='行高: 50px ' { item } }日/view/picker-view-column/picker-view/view/* Json */{ ' navigationbartitetetext ' : ' XXXX ' }总结
以上所述是小编给大家介绍的微信小程序日期选择器实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对我们网站的支持!