我尝试使用uikit制作时间戳,这里是文档https://getuikit.com/v2/docs/timepicker.html
这是我的timepicker data-uk-timepicker="{start:8, end:22}"
但它显示如此,并且没有22:00。我想显示08:00到22:00
答案 0 :(得分:0)
没关系,我改变了uikit js文件,这是代码
function getTimeRange(start, end) {
start = start || 0;
end = end || 24;
var times = {'12h':[], '24h':[]}, i, h;
for (i = start, h=''; i<=end; i++) {
h = ''+i;
if (i<10) h = '0'+h;
times['24h'].push({value: (h+':00')});
if(i!=end) {
times['24h'].push({value: (h+':30')});
}
if (i === 0) {
h = 12;
times['12h'].push({value: (h+':00 AM')});
times['12h'].push({value: (h+':30 AM')});
}
if (i > 0 && i<13 && i!==12) {
times['12h'].push({value: (h+':00 AM')});
times['12h'].push({value: (h+':30 AM')});
}
if (i >= 12) {
h = h-12;
if (h === 0) h = 12;
if (h < 10) h = '0'+String(h);
times['12h'].push({value: (h+':00 PM')});
times['12h'].push({value: (h+':30 PM')});
}
}
return times;
}