答案 0 :(得分:0)
实际上,解决方案非常简单,我只是很着急。 如果您使用的是react-day-picker,则可以利用renderDay属性来计算回历日期并自定义每天的单元格。
这是一个可行的例子
import React from "react";
import ReactDOM from "react-dom";
import DayPicker from "react-day-picker";
import hijriDate from "hijrah-date";
import "react-day-picker/lib/style.css";
import "./styles.css";
const renderDay = day => {
const date = day.getDate();
const hijDate = new hijriDate(day);
const d = hijDate.getDate();
return (
<div>
<span>{date}</span>
<br />
<small>{d}</small>
</div>
);
};
function App() {
return (
<div className="App">
<DayPicker renderDay={renderDay} />
</div>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);