react-day-picker:更改arial-label属性

时间:2017-11-02 17:02:15

标签: javascript accessibility react-day-picker

反应日选择器的当前aria-label格式为

  aria-label="Sun Oct 29 2017"

但如何将其更改为不同的格式,如

  aria-label="29, OCTOBER SUNDAY 2017"
阅读文档无助于找出是否可以自定义

1 个答案:

答案 0 :(得分:1)

您可以更改formatDay功能:

http://react-day-picker.js.org/api/LocaleUtils

返回您喜欢的字符串,例如:

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 } } />