< picker mode = 'date' value = '{{ picker.startDate }}' start = '{{ startLimit }}' end = '{{ picker.endDate }}' bindchange = 'getPickerValue' data-key = 'picker.startDate' > < view class = 'label fs-32 c-gray' >< text >开始日期</ text > {{ picker.startDate }}</ view > </ picker > < picker mode = 'date' value = '{{ picker.endDate }}' start = '{{ picker.startDate }}' bindchange = 'getPickerValue' data-key = 'picker.endDate' > < view class = 'label fs-32 c-gray' >< text >结束日期</ text > {{ picker.endDate }}</ view > </ picker > </ view > |
const miment = require( 'miment' ) Page({ data: { picker: { startLimit: "" , startDate: "" , endDate: "" , realEndDate: "" , } }, onload() { this .initPicker() }, initPicker() { const FORMATER = 'YYYY-MM-DD' const today = new Date() const picker = { startLimit: miment( new Date(0)).format(FORMATER), startDate: miment(today.getFullYear(), today.getMonth() - 1, today.getDate()).format(FORMATER), endDate: miment(today.getFullYear(), today.getMonth(), today.getDate()).format(FORMATER), } if ( new Date(picker.startLimit).getTime() > new Date(picker.startDate).getTime()) { picker.startDate = picker.startLimit } this .setData({ picker }) }, getPickerValue(e) { const { key } = e.currentTarget.dataset this .setData({ [key]: e.detail.value }) }, } |
渲染后的 wxml表现为
System: Android6.0.1
WeChat: 7.0.6 1460
WeChatLib: 2.8.0 (2019.8.8 20:04:12)
你的end就是设置的当天呀
有点乱,麻烦给个代码片段看下(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)
代码片段
我也很无奈啊,就一个用户的手机会这样,其它手机正常
丢人!!!我限制了开始日期不能大于结束日期,我靠这个用户不带脑子的,直接就一句不能选,还以为是bug了
此贴关闭!