weui日期选择器

<script src="/static/mobile/lib/weui.min.js">script>
<div class="weui-cell border-bottom">
    <div class="weui-cell__hd">
        <label for="birth" class="weui-label">龄:label>
    div>
    <div class="weui-cell__bd">
        <input class="weui-input" id="birth" type="text" placeholder="请选择出生日期" readonly>
    div>
div>
$('#birth').on('click', function () {
    weui.datePicker({
        start: 1900,
        end: new Date().getFullYear(),
        defaultValue: ['1990','01','01'],
        onConfirm: function (result) {
            console.log(result);
            if (result[1] < 10){
                result[1] = '0'+result[1];
            }
            if (result[2] < 10){
                result[2] = '0'+result[2];
            }
            $('#birth').val(result.join('-'));
        }
    });
});

你可能感兴趣的:(微信小程序)