datePicker
日期选择或者时间选择
使用方法
AlipayJSBridge.call('datePicker', {
beginDate: '2016-10-10',
minDate: '2016-10-9',
maxDate: '2017-10-9',
mode: 1,
}, function(e) {
alert(JSON.stringify(e));
AlipayJSBridge.call('datePicker', {
minDate: '2015-1-1 0:0:0',
maxDate: '2050-1-1 0:0:0',
mode: 2
},function(e) {
console.log(e);
代码演示
不同模式下的日期/时间选择
<h1>点击按钮查看各个模式下日期选择</h1>
<a href="javascript:void(0)" class="btn date">选择日期</a>
<a href="javascript:void(0)" class="btn time">选择时间</a>
<a href="javascript:void(0)" class="btn datetime">选择日期+时间</a>
<script>
function ready(callback) {
if (window.AlipayJSBridge) {
callback && callback();
} else {
document.addEventListener('AlipayJSBridgeReady', callback, false);
ready(function(){
document.querySelector('.date').addEventListener('click', function() {
AlipayJSBridge.call('datePicker', {
beginDate: '2016-10-10',
minDate: '2016-10-9',
maxDate: '2017-10-9',
mode: 1,
}, function(e) {
alert(JSON.stringify(e));
document.querySelector('.time').addEventListener('click', function() {
AlipayJSBridge.call('datePicker', {
mode: 0,
}, function(e) {
alert(JSON.stringify(e));
document.querySelector('.datetime').addEventListener('click', function() {
AlipayJSBridge.call('datePicker', {
minDate: '2016-10-9',
maxDate: '2017-10-9',
beginDate: '2016-10-9',
mode: 2,
}, function(e) {
alert(JSON.stringify(e));
</script>
身份证日期选择
<h1>点击按钮选择身份证有效期</h1>
<a href="javascript:void(0)" class="btn date">选择日期</a>
<script>
function ready(callback) {
if (window.AlipayJSBridge) {
callback && callback();
} else {
document.addEventListener('AlipayJSBridgeReady', callback, false);
ready(function(){
document.querySelector('.date').addEventListener('click', function() {
AlipayJSBridge.call('datePicker', {
beginDate: '2015-10-12',
minDate: '2015-10-09',
maxDate: '2016-10-09',
mode: 1,
isIDCard: true
}, function(e) {
alert(JSON.stringify(e));