react-day-picker:更改 arial-label 属性
react-day-picker: change arial-label attribute
react-day-picker 的当前 aria-label 格式是
aria-label="Sun Oct 29 2017"
但是如何将其更改为不同的格式,例如
aria-label="29, OCTOBER SUNDAY 2017"
阅读文档无助于确定是否可以自定义
您可以更改 formatDay
函数:
http://react-day-picker.js.org/api/LocaleUtils
到return您喜欢的字符串,例如:
import DayPicker, { LocaleUtils } from "react-day-picker";
function formatDay(d, locale) {
return <span>{d.getDate()}-s{d.getMonth()}-{d.getFullYear()}</span>
}
<DayPicker localeUtils={ { ...LocaleUtils, formatDay } } />
react-day-picker 的当前 aria-label 格式是
aria-label="Sun Oct 29 2017"
但是如何将其更改为不同的格式,例如
aria-label="29, OCTOBER SUNDAY 2017"
阅读文档无助于确定是否可以自定义
您可以更改 formatDay
函数:
http://react-day-picker.js.org/api/LocaleUtils
到return您喜欢的字符串,例如:
import DayPicker, { LocaleUtils } from "react-day-picker";
function formatDay(d, locale) {
return <span>{d.getDate()}-s{d.getMonth()}-{d.getFullYear()}</span>
}
<DayPicker localeUtils={ { ...LocaleUtils, formatDay } } />