如何在 ts 中使用'@devexpress/dx-react-scheduler'?它会导致打字稿错误



我想使用'@devexpress/dx-react scheduler'库。

但它会导致Typescript错误,如under。

类型"{childrens:Element[];data:AppointmentModel[];}"不是可分配给类型'IntrinsicAttributes&SchedulerProps的。所有物类型"IntrnsicAttributes&SchedulerProps的。

我把它和官方文档中的一样(https://devexpress.github.io/devextreme-reactive/react/scheduler/docs/guides/typescript/),但以下错误也出现在官方文档中。

不同的是,官方文件只显示了一个警告(https://codesandbox.io/s/fcj6pm),

import * as React from 'react';
import Paper from '@mui/material/Paper';
import { AppointmentModel, ViewState, SchedulerDateTime } from '@devexpress/dx-react-scheduler';
import {
Scheduler, DayView, Appointments, Resources,
} from '@devexpress/dx-react-scheduler-material-ui';

const Demo = () => {
const [currentDate, setCurrentDate] = React.useState<SchedulerDateTime>('2018-10-31');
return (
<Paper>
<Scheduler
data={appointments}
>
<ViewState
currentDate={currentDate}
onCurrentDateChange={setCurrentDate}
/>
<DayView
startDayHour={7}
endDayHour={12}
/>
<Appointments />
<Resources
data={resources}
/>
</Scheduler>
</Paper>
);
};
export default Demo;

但我收到一个错误(不仅仅是警告(,屏幕没有出现。

我该怎么办。。?

很抱歉我回答得太晚了。似乎您必须使用"@devexpress/dx-react调度器";。然后设置所需道具。

像这样:(sudo代码(。rootComponent从"@devexpress/dx-react调度器材料ui";

import {
Scheduler as MuiSchedular,
DayView, 
Appointments, 
Resources,

} from "@devexpress/dx-react-scheduler-material-ui";
import {
AppointmentModel,
Scheduler,
ViewState,
} from "@devexpress/dx-react-scheduler";

export const Calendar = () => {
const rootComponent = (props: Scheduler.RootProps) => {
return <MuiSchedular.Root {...props} />
};
return (
<Paper>
<Scheduler
height={"auto"}
firstDayOfWeek={1}
rootComponent={rootComponent}
data={appointments ?? []}
locale={"da-DK"}
>
<ViewState
currentDate={currentDate}
onCurrentDateChange={setCurrentDate}
/>
<DayView
startDayHour={7}
endDayHour={12}
/>
<Appointments />
<Resources data={resources} />
</Scheduler>
</Paper>
);
}

最新更新