admin管理员组文章数量:1023018
I try to change format of days in Date/month picker ponent. At the moment list of days as "M,T,W,T,F,S,S", but I need "Mo,Tu,We,Th,Fr,Sa,Su". In API I can see that necessary parameter called "day-format" and its value is null (default). Can anybody please explain: is it possible to change this format of days?
Here is the API of Vuetify:
I try to change format of days in Date/month picker ponent. At the moment list of days as "M,T,W,T,F,S,S", but I need "Mo,Tu,We,Th,Fr,Sa,Su". In API I can see that necessary parameter called "day-format" and its value is null (default). Can anybody please explain: is it possible to change this format of days?
Here is the API of Vuetify: https://vuetifyjs./en/ponents/date-pickers#date-month-pickers
Share Improve this question edited Aug 20, 2019 at 16:22 Daniel 35.8k17 gold badges114 silver badges161 bronze badges asked Aug 20, 2019 at 16:19 ZmagarochakZmagarochak 3731 gold badge3 silver badges9 bronze badges3 Answers
Reset to default 3- Use the
weekday-format
to pass the date to a function; - Convert the date to day of the week (0..6)
- Use that as the index for an array of strings ('Mo'..'Su')
code:
<div id="app">
<v-app id="inspire">
<v-row justify="center">
<v-date-picker :weekday-format="getDay" v-model="picker"></v-date-picker>
</v-row>
</v-app>
</div>
const daysOfWeek = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
new Vue({
el: '#app',
vuetify: new Vuetify(),
data () {
return {
picker: new Date().toISOString().substr(0, 10),
}
},
methods:{
getDay(date){
let i = new Date(date).getDay(date)
return daysOfWeek[i]
}
}
})
Multiple ways to solve for this, but I somewhat reverse-engineered their source to find out more about the properties that's being passed into the weekday-format prop:
<div>
<v-calendar
:weekday-format="formatWeekDay"
/>
</div>
const calendar = {
name: 'Calendar',
methods: {
formatWeekDay(props) {
return new Date(props.date.replace(/-/g, '\/')).toLocaleDateString('en-US', {weekday: 'narrow'});
}
}
};
I took some guidance from this answer to determine the best way to parse the date being provided back. You can read more about how the locale functionality works, here.
Use the first-day-of-week to pass the date to a function
<v-date-picker v-model="date" :first-day-of-week="1">
I try to change format of days in Date/month picker ponent. At the moment list of days as "M,T,W,T,F,S,S", but I need "Mo,Tu,We,Th,Fr,Sa,Su". In API I can see that necessary parameter called "day-format" and its value is null (default). Can anybody please explain: is it possible to change this format of days?
Here is the API of Vuetify:
I try to change format of days in Date/month picker ponent. At the moment list of days as "M,T,W,T,F,S,S", but I need "Mo,Tu,We,Th,Fr,Sa,Su". In API I can see that necessary parameter called "day-format" and its value is null (default). Can anybody please explain: is it possible to change this format of days?
Here is the API of Vuetify: https://vuetifyjs./en/ponents/date-pickers#date-month-pickers
Share Improve this question edited Aug 20, 2019 at 16:22 Daniel 35.8k17 gold badges114 silver badges161 bronze badges asked Aug 20, 2019 at 16:19 ZmagarochakZmagarochak 3731 gold badge3 silver badges9 bronze badges3 Answers
Reset to default 3- Use the
weekday-format
to pass the date to a function; - Convert the date to day of the week (0..6)
- Use that as the index for an array of strings ('Mo'..'Su')
code:
<div id="app">
<v-app id="inspire">
<v-row justify="center">
<v-date-picker :weekday-format="getDay" v-model="picker"></v-date-picker>
</v-row>
</v-app>
</div>
const daysOfWeek = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'];
new Vue({
el: '#app',
vuetify: new Vuetify(),
data () {
return {
picker: new Date().toISOString().substr(0, 10),
}
},
methods:{
getDay(date){
let i = new Date(date).getDay(date)
return daysOfWeek[i]
}
}
})
Multiple ways to solve for this, but I somewhat reverse-engineered their source to find out more about the properties that's being passed into the weekday-format prop:
<div>
<v-calendar
:weekday-format="formatWeekDay"
/>
</div>
const calendar = {
name: 'Calendar',
methods: {
formatWeekDay(props) {
return new Date(props.date.replace(/-/g, '\/')).toLocaleDateString('en-US', {weekday: 'narrow'});
}
}
};
I took some guidance from this answer to determine the best way to parse the date being provided back. You can read more about how the locale functionality works, here.
Use the first-day-of-week to pass the date to a function
<v-date-picker v-model="date" :first-day-of-week="1">
本文标签:
版权声明:本文标题:javascript - How to change day-format (M > Mo, F > Fr...) in Datemonth pickers of Vuetify - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745497646a2153240.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论