Develop a simple mobile-side time picker that supports multiple themes and now shares it.
GitHub Address: Https://github.com/IronPans/LazyPicker: You can also scan the QR code with the phone experience: 1.2 Version experience: If you use a PC browser, then you need to switch to phone mode to use. Step: Press F12 or right mouse button--click Check, then click on the upper left corner of the console phone mode button. Address: Click hereHow to useIntroduce CSS and JavaScript scripts:
<link rel= "stylesheet" href= "LazyPicker.min.css"/><script src= "LazyPicker.min.js" ></script>
simple Form (input)
<input type= "text" class= "Date-picker" placeholder= "Select Date"/>
Initialize time picker
var picker = new Lazypicker ('. Date-picker ');
Here'sclassCustomizable, but to correspond to the one you want to set as the time pickerinputOfclass。Optional ParametersThe Lazypicker constructor can set the second parameter, which is the configuration object, which can be set up with parameter descriptions:
Theme:, //Theme green (Dark Black) Initdate:, //Set initial date, format Yyyy-mm-dd or yyyy/mm/ddmindate:, // Set the minimum year, default is 1950maxDate:, //Set the maximum year, default is the initial year + 20, if initdate and maxdate exist simultaneously, the year is dominated by MaxDate. Onchange:function (data) { ///Listen Select time change //Data Returns an object that contains the attributes year, month, day, date, respectively, representing years, months, days, years-months-days}
new features in version 1.2
Data:/ /Custom selection, JSON format type: //style, temporarily support, default is 1, when set to 2 o'clock, style can scan QR code to see the fifth (that is, orange color that, there will be a little difference)
JSON format description for data:
var data = { "item": [{ /* First item */ "id": 1, "name": "Guangdong",/ * Name attribute is required, ID optional * /"child": [{/ * subkey * /"id": 101, "name": "Guangzhou", "child": [{ /* sub-subkey */ "id": 3, "name": "Tianhe District" }] }] }, { "id": 1, "name": "Yunnan", "selected": True,/ * default option, when set to True, the current item that opens the selector is this */ " Child ": [{ " id ": 1, " name ":" Kunming " }, { " id ": 1, " name ":" Yuxi ", " selected ": True/ * Default option */ }, { "id": 1, "name": "Lijiang" }] }, { "id": 1, "name": "Shanghai", "Child": [{ c38/> "id": 1, "name": "Shanghai" }] }], "ItemName": "Province-city-zone"/ * Option Header description hint */};
When it is a custom format,onChangeValue returned by the methoddataare also different:
[ [Name,id],[name,id].....,name-name-name]
Multiple arrays represent the name of each option (name) andid, the last item is the name value string with a "-" connection, which isinputThe value. If you find a bug or have a better suggestion, strongly implore comments in the comment section below to inform you that your support is the way to improve the lazypicker.
Mobile time Selector (update 1.2.0 version)