这是我的示例数据
$(function(){
$('#slider-date').noUiSlider({
behaviour: 'drag',
connect: true,
range: {
'min': timestamp('2015-03-08 11:52:30'),
'max': timestamp('2015-03-09 11:52:02')
},
// Steps of one week
step: 7 * 24 * 60 * 60 * 1000,
// Two more timestamps indicate the handle starting positions.
start: [ timestamp('2015-03-08 11:52:30'), timestamp('2015-03-09 13:29:34') ],
// No decimals
format: wNumb({
decimals: 0
})
});
$("#slider-date").Link('lower').to($("#event-start"), setDate);
$("#slider-date").Link('upper').to($("#event-end"), setDate);
// Create a new date from a string, return as a timestamp.
function timestamp(str){
return new Date(str).getTime();
}
// Create a list of day and monthnames.
var
weekdays = [
"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday",
"Saturday"
],
months = [
"January", "February", "March",
"April", "May", "June", "July",
"August", "September", "October",
"November", "December"
];
// Append a suffix to dates.
// Example: 23 => 23rd, 1 => 1st.
function nth (d) {
if(d>3 && d<21) return 'th';
switch (d % 10) {
case 1: return "st";
case 2: return "nd";
case 3: return "rd";
default: return "th";
}
}
// Create a string representation of the date.
function formatDate ( date ) {
console.log(date.getDate());
return weekdays[date.getDay()] + ", " +
date.getDate() + nth(date.getDate()) + " " +
months[date.getMonth()] + " " +
date.getFullYear();
}
// Write a date as a pretty value.
function setDate( value ){
return $(this).html(formatDate(new Date(+value)));
}
});
这是插件页面,我从 http://refreshless.com/nouislider/examples/#section-dates获得代码结构
在示例中,他们提供了一年作为开始/结束最小值/最大值。我提供了一个时间戳。可能是问题。没有把握。
这是发生错误的控制台的屏幕截图。它正在检查2015-03-08
错误期间的日期,这是对应于 的星期日0
。不确定是什么问题。