//注意以下that.×××是因为我用的layui+vue 所以纯使用layui的读者需要更改that.××× = 要更改为var ××× =
// 查询开始日期 insStart不需要定义
that.insStart = that.laydate.render({
elem: '#startDetectDate'
, showBottom: true
, value: that.startDetectDate
, trigger: 'click'
, done: function (value, date) {
//更新结束日期的最小日期
that.insEnd.config.min = lay.extend({}, date, {
month: date.month - 1
});
}
});
// 查询结束日期 insEnd不需要定义
that.insEnd = that.laydate.render({
elem: '#endDetectDate'
, min: 0
, showBottom: true
, value: that.endDetectDate
, trigger: 'click'
, done: function (value, date) {
//更新开始日期的最大日期
/*that.insStart.config.max = lay.extend({}, date, {
month: date.month - 1
});*/
}
});
记一次日期组件的问题:layui日期组件在第一次渲染完成后 进行重复的form.render()渲染是不会生效的所以我们只能让组件强制的去渲染,如下操作
<div class="layui-input-inline layui-input-i-icon" id="reloadDate">
<i class="layui-icon layui-icon-date"></i>
<input type="text" class="layui-input" autocomplete="off" id="firstUseDate1" lay-verify="required" lay-verType="tips" readonly>
</div>
if (that.insEnd) {
that.$('#firstUseDate1').remove();
that.$('#reloadDate').append('<input type="text" class="layui-input" autocomplete="off" id="firstUseDate1" lay-verify="required" lay-verType="tips" readonly>');
that.insEnd = that.laydate.render({
elem: '#endDetectDate'
, showBottom: true
, type: 'date'
, max: moment().format('YYYY-MM-DD')
, min: data.setUpDate
, value: new Date()
, trigger: 'click'
, done: function (value, d) {
}
});
} else {
that.$nextTick(function () {
//开始日期
that.insEnd = that.laydate.render({
elem: '#endDetectDate'
, showBottom: true
, type: 'date'
, max: moment().format('YYYY-MM-DD')
, min: data.setUpDate
, trigger: 'click'
, done: function (value, d) {
}
});
});
}