相关疑难解决方法(0)

React Big Calendar如何在月视图中设置一天的样式

因此,如图所示,我想对单个事件进行样式设置。

外观示例

使用slotpropgetter可以有条件地渲染样式。

slotPropGetter = date => {
    const CURRENT_DATE = moment().toDate();
    let backgroundColor;

    if (moment(date).isBefore(CURRENT_DATE, "month")) {
        backgroundColor = "#f7f8f9";
    }

    var style = {
        backgroundColor
    };
    return {
        style: style
    };
};
Run Code Online (Sandbox Code Playgroud)

因此,“解决方案”是DateCellWrapper,它要么对我不起作用,要么我以错误的方式实现了它

const DateCellWrapper = ({ value, children }) => {
    console.log("DateCellWrapper")
    const style = {
        backgroundColor: "#000",
    };

    return (
        <div style={style}>{children}</div>
    );
}
Run Code Online (Sandbox Code Playgroud)

它甚至不输出我的console.log,所以..有人知道吗?:p

javascript css reactjs react-big-calendar

5
推荐指数
1
解决办法
5476
查看次数

标签 统计

css ×1

javascript ×1

react-big-calendar ×1

reactjs ×1