我有这个使用剑道UI调度程序的应用程序,我现在有两个视图:
views: [
{ type: "day", selected: false, majorTick: majorTick },
{ type: "week", selected: true, majorTick: majorTick },
]
问题是我需要将视图更改为day
用户是否在移动设备中,否则将其保留week
。
任何帮助将不胜感激。
好吧,我找到了这个解决方案,首先我检查该应用程序是否像这样在移动设备中:
detectmobile(): boolean {
if (navigator.userAgent.match(/Android/i)
|| navigator.userAgent.match(/webOS/i)
|| navigator.userAgent.match(/iPhone/i)
|| navigator.userAgent.match(/iPad/i)
|| navigator.userAgent.match(/iPod/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Windows Phone/i)
|| (window.innerWidth <= 800 && window.innerHeight <= 600)) {
return true;
}
else {
return false;
}
}
然后我简单地计算我的布尔值:
let detectMobile = this.detectmobile();
let isDay = detectMobile;
let isWeek = !detectMobile;
最后我把它们喂给jQuery("#scheduler").kendoScheduler
:
views: [
{ type: "day", selected: isDay, majorTick: majorTick },
{ type: "week", selected: isWeek, majorTick: majorTick },
],