前言
由于网上找的要么就是只能初始不能重置、不能赋值…,没有合适自己的就自己写了一个
基于jquery实现的,H5移动端选择器
默认自带日期选择,可自定义类型选择,和自定义html,支持重置、赋值、各种事件回调等
效果图
微信模拟版
旧版
使用方式简单
layPicker.init({ elem: '#year', // 绑定元素 options: 'year', // 设置为日期选择器(日期选择器可设置:year、month、date、time、timesecond、datetime、datetimesecond),不设置默认取data作为选择值 onSuccess: function(index, elem){ // 渲染成功回调 layPicker.setValue(index, [ {value: '2023'}, ]) }, onSelect: function(result){ console.log('onSelect --- ', JSON.stringify(result)) }, onConfirm: function(index, value, result){ // 点击确认回调 $("#year").val(value) console.log('onConfirm --- ', index, '---', value, '----', JSON.stringify(result)) }, onCancel: function(index){ // 点击取消回调 }, onShade: function(index){ // 点击遮罩回调 }, })
复制
CSDN下载(要积分):https://download.csdn.net/download/weixin_43992507/88327238
gitee下载(免费):https://gitee.com/yuanyongqiang/lay-picker