gpt4 book ai didi

react-day-picker - 为 react-day-picker 添加一个类?

转载 作者:行者123 更新时间:2023-12-04 08:28:24 26 4
gpt4 key购买 nike

如何将类添加到 react-day-picker 的今天按钮?

从文档中似乎是可能的:
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,它需要以下键(即,它需要容器、包装器、..months..month..day.. 等键),但您只提供 todayButton 键/值,显然您需要提供每个键/值对。

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

import classNames from '../classNames' // this path is probably not correct

const dayPickerClassNames = { ...classNames, todayButton: 'newClass' };

<DayPicker
classNames={dayPickerClassNames}
/>

关于react-day-picker - 为 react-day-picker 添加一个类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48210311/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com