反应路由器:确切不适用于TypeScript

时间:2020-08-06 13:33:41

标签: reactjs

我在准确上出现错误:

<Switch>
 <Route path="/a" exact component={() => <div>Home page</div>}</Route> 
</Switch>

错误是:

Type '{ path: string; exact: true; component: () => Element; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<RouteProps, any, any>> & Readonly<RouteProps> & Readonly<...>'.
Property 'exact' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<RouteProps, any, any>> & Readonly<RouteProps> & Readonly<...>'.ts(2322)

那么,这是怎么回事? 我正在从react-router-dom导入组件。并且也有@types。在index.d.ts中,RouteProps没有exact?: Boolean

0 个答案:

没有答案