我正在尝试在我自己的工作台上运行 Fluent UI Basic List 示例。该示例在此处提供:https ://developer.microsoft.com/en-us/fluentui#/controls/web/list 。我将整个示例的代码复制到应用程序,并用我自己的数组替换了示例的数据。但是我收到以下错误:
Type '(item: IExampleItem, index: number | undefined) => JSX.Element' is not assignable to type
'(item?: { key: number; name: string; } | undefined, index?: number | undefined, isScrolling?:
boolean | undefined) => ReactNode'.`
Types of parameters 'item' and 'item' are incompatible.
Type '{ key: number; name: string; } | undefined' is not assignable to type 'IExampleItem'.
Type 'undefined' is not assignable to type 'IExampleItem'. TS2322
83 |
84 |
85 | <List items={data} onRenderCell={onRenderCell} />
| ^
86 |
87 | );
88 | };
是因为这是一个打字稿文件吗?我应该禁用某些东西来更改编译并防止此类错误吗?
更改后我的代码如下所示:https ://codepen.io/vipperdev/pen/QWNdeJe