【发布时间】:2021-12-18 05:53:03
【问题描述】:
我正在使用 Fluent UI,导入了 Toggle 组件并导出了 UI Toggle:
export const UIToggle: React.FunctionComponent = () => {
return (
<Stack tokens={stackTokens}>
<Toggle label="Enabled and checked" defaultChecked onText="On" offText="Off" />
</Stack>
);
};
但是当我想使用它并更新“标签”属性时:
<UIToggle label = "Turn on"></UIToggle>
这是错误:
Type '{ label: string; }' is not assignable to type 'IntrinsicAttributes & { children?: ReactNode; }'.
Property 'label' does not exist on type 'IntrinsicAttributes & { children?: ReactNode; }'
谁能解释为什么会出现这个错误以及我该如何解决?
【问题讨论】:
-
您是否尝试将
label传递给函数,例如:React.FunctionComponent = ({label}) => {...?
标签: javascript reactjs typescript fluent-ui fluentui-react