// 这是我项目中用到的,shortcutOptions你可以自己选择要不要加,主要就是参数between: 'month',不能跨月选择
var api = { shortcutMonth: function() { // 当月 var nowDay = moment().get('date'); var prevMonthFirstDay = moment().subtract(1, 'months').set({ 'date': 1 }); var prevMonthDay = moment().diff(prevMonthFirstDay, 'days'); return { now: '-' + nowDay + ',0', prev: '-' + prevMonthDay + ',-' + nowDay } }, // 快捷选项option:只能同一个月份内的 rangeMonthShortcutOption1: function() { var result = api.shortcutMonth(); return [{ name: '昨天', day: '-1,-1', time: '00:00:00,23:59:59' }, { name: '当月', day: result.now, time: '00:00:00,' }, { name: '上一月', day: result.prev, time: '00:00:00,23:59:59' }]; } } $('.J-datePicker-range-betweenMonth').datePicker({ isRange: true, between: 'month', hasShortcut: true, //shortcutOptions:window.api.rangeMonthShortcutOption1() });