<div class="layui-input-inline">
<input type="text" name="username" placeholder="请选择要查询的年月" class="layui-input" id="test1">
</div>
引入layui文件
<link href="../../lib/layui-v2.6.8/layui/css/layui.css" rel="stylesheet" />
<script src="../../lib/layui-v2.6.8/layui/layui.js"></script>
设置script
<script>
layui.use('laydate', function () {
var laydate = layui.laydate;
var month = new Date().getMonth() + 1;
month = (month < 10 ? "0" + month : month);
//执行一个laydate实例
laydate.render({
elem: '#test1', //指定元素
type: 'month'
//, show: true //直接显示
, value: new Date().getFullYear() + "-" + month
});
});
</script>
效果图