diff --git a/examples/laydate.html b/examples/laydate.html index 1d8bf2b6..3d59aa68 100644 --- a/examples/laydate.html +++ b/examples/laydate.html @@ -55,6 +55,11 @@ body{padding: 50px 100px;} +开启快捷面板: +
+ +
+



年选择器: @@ -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({