更新 laydate 快捷选择面板示例

pull/1181/head
贤心 2022-12-07 18:18:00 +08:00
parent c81ba044a4
commit a7017c3daf
1 changed files with 54 additions and 1 deletions

View File

@ -55,6 +55,11 @@ body{padding: 50px 100px;}
<input type="text" class="layui-input" id="test2">
</div>
开启快捷面板:
<div class="layui-inline">
<input type="text" class="layui-input" id="test2-1">
</div>
<br><br><hr><br>
年选择器:
@ -192,7 +197,7 @@ layui.use('laydate', function(laydate){
});
//单控件
// 日期选择器(单面板)
laydate.render({
elem: '#test2'
//,format: 'yyyy年MM月dd日'
@ -215,6 +220,54 @@ layui.use('laydate', function(laydate){
console.log(value);
}
});
// 开启快捷面板
laydate.render({
elem: '#test2-1',
shortcuts: [
{
text: "昨天",
value: (function () {
var now = new Date();
now.setDate(now.getDate() - 1);
return now;
})()
},
{ text: "今天", value: Date.now() },
{
text: "明天",
value: (function () {
var now = new Date();
now.setDate(now.getDate() + 1);
return now;
})()
},
{
text: "上个月",
value: (function () {
var now = new Date();
// now.setDate(now.getDate() - 1);
now.setMonth(now.getMonth() - 1);
return [now];
})()
},
{
text: "上个月的前一天",
value: (function () {
var now = new Date();
now.setMonth(now.getMonth() - 1);
now.setDate(now.getDate() - 1);
return [now];
})()
},
{
text: "某一天",
value: "2020-12-12"
}
]
})
//年选择器
laydate.render({