1.js里面调用:
$("#sf_last_time").datepicker({
format:'yyyy-mm',
autoclose:true,//自动关闭
minViewMode:1,
startView:1,
language:'zh-CN',
});
2.html里面书写:
<div class="input-group">
<input type="text" class="input-datepicker form-control" data-date-start-view="1" data-date-min-view-mode="1" data-date-format="yyyy-mm" id="sa_time" placeholder="开始时间"><span class="input-group-addon"><i class="fa fa-chevron-right"></i></span>
<input type="text" class="input-datepicker form-control" data-date-start-view="1" data-date-min-view-mode="1" data-date-format="yyyy-mm" id="sa_time2" placeholder="结束时间"></div>
注:如果要光选择年份,只需把data-date-start-view和data-date-min-view-mode改为2,,format改为"yyyy";