【问题标题】:Typescript 2 types with react-router, cannot find name path, component带有 react-router 的 Typescript 2 类型,找不到名称路径、组件
【发布时间】:2017-06-03 15:18:00
【问题描述】:

屏幕截图不言自明,首先这是我出现问题的路由文件,您可以看到未使用的导入以及找不到路径和组件。

这是我的 package.json,其中包含类型依赖项和 node_modules 文件夹中的 @types。

最后,我的配置

我不知道问题出在哪里,有人有类似的吗?

请注意,我已经能够在应用程序中使用 <Router history={browserHistory} routes={routes} /> 和 react 和 redux 对象而没有问题。

【问题讨论】:

标签: reactjs typescript react-router typescript-typings typescript2.0


【解决方案1】:

您的 routes 文件具有 .ts 扩展名,但如果它包含 JSX,则应为 .tsx

【讨论】:

    猜你喜欢
    • 2018-12-11
    • 2019-06-30
    • 2017-12-16
    • 2019-11-09
    • 2021-08-04
    • 2020-01-03
    • 2017-02-02
    • 2017-09-22
    • 2017-03-25
    相关资源
    最近更新 更多