简体   繁体   English

如何将 vuetify 日历间隔格式更改为 24 小时?

[英]How to change vuetify calendar interval format to 24 hours?

I'm using vuetify calendar with type week and it shows time in 12 hour format with AM and PM.我正在使用类型为 week 的 vuetify 日历,它以 12 小时格式显示时间,包括 AM 和 PM。 How do i change that to 24 hour format?我如何将其更改为 24 小时格式?

I looked at the documentation and didn't find much, except that u can pass interval-format prop that expects a function.我查看了文档并没有找到太多内容,除了您可以传递期望函数的间隔格式道具。 Also found a function at vuetify github.还在 vuetify github 上找到了一个函数。

    <v-calendar
                :now="today"
                :value="today"
                color="primary"
                locale="et"
                type="week"
                :interval-format="intervalFormat"
            >
            </v-calendar>

methods: {
        intervalFormat() {
            const longOptions = { timeZone: 'UTC', hour12: true, hour: '2-digit', minute: '2-digit' }
            const shortOptions = { timeZone: 'UTC', hour12: true, hour: 'numeric', minute: '2-digit' }
            const shortHourOptions = { timeZone: 'UTC', hour12: true, hour: 'numeric' }

            return longOptions
        }
    }

I wanted 24 hour format but it's still 12 hour format我想要 24 小时格式,但它仍然是 12 小时格式

Got it.知道了。

intervalFormat(interval) {
        return interval.time
    }

Add this to your v-calendar:将此添加到您的 v 日历:

 :interval-format="intervalFormat"

Create a new function equal to this:创建一个与此相等的新函数:

  intervalFormatter(locale, getOptions) {
     return locale.time;
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM