如何使今天的日期(v-present)始终位于 vuetify 日历的中间列
Posted
技术标签:
【中文标题】如何使今天的日期(v-present)始终位于 vuetify 日历的中间列【英文标题】:how to make today date (v-present) always the middle column in vuetify calendar 【发布时间】:2022-01-04 05:16:34 【问题描述】:vuetify v-calendar 在 Type week 中有特定的天数顺序(sun to sat),然后根据今天的日期从左到右移动类 v-present,如何使今天的日期在中间列中有(v-present) enter image description here
【问题讨论】:
【参考方案1】:经过大量时间一遍又一遍地搜索和阅读文档后,我找到了一个解决方案,v-calendar 采用了一个名为 weekdays 的道具,它是一个数组,其中星期从太阳 (0) 开始并在星期六 (6) 结束是该道具的默认形式 [0,1,2,3,4,5,6]
所以我在数据属性中创建了 weekDays 然后在挂载的钩子中运行这个方法它可以工作
getWeekDays()
const dayNames = ["Sun", "Mon", "Tues", "Wed", "Thu", "Fri", "Sat"];
let dateObj = new Date();
let dayName = dayNames[dateObj.getDay()];
switch(dayName)
case"Sun":
this.weekDays = [4,5,6,0,1,2,3]
break;
case"Mon":
this.weekDays = [5,6,0,1,2,3,4]
break;
case"Tues":
this.weekDays = [6,0,1,2,3,4,5]
break;
case"Wed":
this.weekDays = [0,1,2,3,4,5,6]
break;
case"Thu":
this.weekDays = [1,2,3,4,5,6,0]
break;
case"Fri":
this.weekDays = [2,3,4,5,6,0,1]
break;
case"Sat":
this.weekDays = [3,4,5,6,0,1,2]
break;
default:
this.weekDays = [0,1,2,3,4,5,6]
,
【讨论】:
以上是关于如何使今天的日期(v-present)始终位于 vuetify 日历的中间列的主要内容,如果未能解决你的问题,请参考以下文章
如何使页脚视图始终位于 UITableViewController 的底部?