摘要:再得的基礎(chǔ)上修改為類似選擇時(shí)間的插件。普通示例年月月月年年年月日月的最后一天要加原本是從開始的但是因?yàn)槭沁@個(gè)月的上個(gè)月所以到了上個(gè)月日日月月年年小時(shí)分鐘效果圖年月日小時(shí)分鐘效果只有在手機(jī)端或者手機(jī)的手機(jī)模擬器中可以看到。
再mui得picker的基礎(chǔ)上修改為類似ios選擇時(shí)間的插件。
muipicker exapmple地址
把里面數(shù)據(jù)換成下面的數(shù)據(jù)就可以了。
(function($, doc) { $.init(); $.ready(function() { //普通示例 // 年月 var yearArray = new Array(); for (var i = 0; i < 10; i ++) { var monthArray = new Array(); for (var j = 0; j < 12; j ++) { var month = new Object(); month.value = j + 1 + "月"; month.text = j + 1 + "月"; monthArray.push(month); } var year = new Object(); year.value = i + 2016 + "年" ; year.text = i + 2016 + "年"; year.children = monthArray; yearArray.push(year); }; //年月日 var yearArray = new Array(); for (var i = 0; i < 10; i ++) { var monthArray = new Array(); for (var j = 0; j < 12; j ++) { //月的最后一天 var year = i + 2016; var month = j; var lastDay = new Date(year, month + 1, 0).getDate();//month 要加1,原本month是從0開始的,但是因?yàn)?是這個(gè)月的上個(gè)月,所以到了上個(gè)月. if(year == 2016 && month == 1) { console.log("lastday" + lastDay); } var dayArray = new Array(); for(var k = 0; k < lastDay; k ++) { var day = new Object(); day.value = k + 1 + "日"; day.text = k + 1 + "日"; dayArray.push(day); } var month = new Object(); month.children = dayArray; month.value = j + 1 + "月"; month.text = j + 1 + "月"; monthArray.push(month); } var year = new Object(); year.value = i + 2016 + "年" ; year.text = i + 2016 + "年"; year.children = monthArray; yearArray.push(year); }; console.log(yearArray); // 小時(shí)分鐘 var hoursec = new Array(); for (var i = 0; i < 24; i ++) { var hsChildrenArray = new Array(); for (var j = 0; j < 60; j ++) { var childrenObject = new Object(); var secTrue = j ; if(j < 10) { var secTrue = j ; childrenObject.value = "0" + secTrue; childrenObject.text = "0" + secTrue; }else { childrenObject.value = secTrue ; childrenObject.text = secTrue; } hsChildrenArray.push(childrenObject); } var object = new Object(); if(i < 10) { object.value = "0" + i + ":" ; object.text = "0" + i + ":"; }else { object.value = i +":" ; object.text = i + ":"; } object.children = hsChildrenArray; hoursec.push(object); }; }); })(mui, document);
效果圖:
年月日
小時(shí)分鐘
效果只有在手機(jī)端或者手機(jī)chrome的手機(jī)模擬器中可以看到。
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://specialneedsforspecialkids.com/yun/78717.html
閱讀 2401·2021-10-09 09:44
閱讀 2138·2021-10-08 10:05
閱讀 3428·2021-07-26 23:38
閱讀 3000·2019-08-28 18:16
閱讀 816·2019-08-26 11:55
閱讀 1826·2019-08-23 18:29
閱讀 2039·2019-08-23 18:05
閱讀 1368·2019-08-23 17:02