//js加载函数中定义视图
$(".date-picker-month").datepicker({
// format: 'yyyy-mm', 格式化日期
language: "zh-CN",
autoclose : true,
clearBtn : true,//清除按钮
// todayBtn : true,//今日按钮
todayHighlight : true,
minViewMode: 1, //1 为月,2为年,3为日
maxViewMode: 1
});
html定义
<div class="input-group input-medium date-picker-month input-daterange" data-date-format="yyyy年mm月" >
<input id="queryMonth" name="queryMonth" autocomplete=off class="form-control date-picker-month" type="text" value="">
</div>
显示效果
帮助文档:Options — bootstrap-datepicker documentation
中文帮助文档:https://www.itxst.com/bootstrap-datepicker/2q3uzafn.html