将类添加到反应日选择器



如何将类添加到反应日选择器的今天按钮?

从文档中似乎可以:http://react-day-picker.js.org/api/DayPicker#classNames

const dayPickerClassNames = { todayButton: 'newClass' };
<DayPicker
  classNames={dayPickerClassNames}
/>

但是我收到一个错误:

Warning: Failed prop type: The prop `classNames.day` is marked as required in `DayPicker`, but its value is `undefined`.
根据 API 的说法,它需要

以下键(即,它需要容器、包装器、.. 月.. 月.. 日等键(,但你只提供 todayButton 键/值,显然你需要提供每个键/值对。

您应该能够导入默认的classNames对象,然后像这样更新todayButton值:

import classNames from '../classNames' // this path is probably not correct
const dayPickerClassNames = { ...classNames, todayButton: 'newClass' };
<DayPicker
  classNames={dayPickerClassNames}
/>
const defaultClassNames = DayPicker.defaultProps.classNames,
      newClassNames = { ...datePickerClassNames,
                        container: `${defaultClassNames.container} MY_CONTAINER`
                      };
...
<DayPicker classNames={dayPickerClassNames}/>

我建议使用您自己的类附加默认类,如上面的示例中,默认container类附加MY_CONTAINER类。

我相信

它可能只是解析单词day并为解析的day*******寻找类名,我想我会尝试定义key:value关系,就像他们在文档中所做的那样。

// const dayPickerClassNames = { todayButton: 'newClass' };
<DayPicker
  classNames={ todayButton: 'newClass' }
/>

相关内容

  • 没有找到相关文章

最新更新