Bootstrap 日期范围选择器仅查看月份和年份 [英] Bootstrap date range picker view month and year only
问题描述
我构建了一个包含月份范围的表单.我正在使用 daterangepicker bootstrap 来做到这一点.例如从一月到四月,但我不能只使用 viewMode: 'months' 显示月视图,或者可能有另一个代码只显示月?
i build a form that contain month range. i am using daterangepicker bootstrap to do it. For example from Jan to April, but i cannot display month view only using viewMode: 'months', or may be there is another code to display month only?
这是我的js代码:
$(function () {
$('#growthrange').daterangepicker({
format: 'MM/yyyy',
viewMode: 'months',
minViewMode: 'months',
autoclose: true,
locale: {
applyLabel: 'Apply Date',
fromLabel: 'First Date',
toLabel: 'Second Date',
monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
firstDay: 1
}
},
function (start, end) {
$('#growthrange span').html(start.toString('MMMM, yyyy') + '-' + end.toString('MMMM, yyyy'));
});
请帮忙!
推荐答案
我也是,我试图找到解决方案,但没有一个真正适合我的上下文,这就是我实现它的原因(有更多选项和事件侦听器):如果帖子太晚了,希望这可以帮助其他人:
Me too, I tried to find solution but none really work for my context, here's whay I implemented it (with more options & event listener) : Hope this can help others if its too late for the post:
在此处查看 git repo(不要犹豫贡献)
See here the git repo (Don't hesitate to contribute)
这篇关于Bootstrap 日期范围选择器仅查看月份和年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!