【问题标题】:Typescript + VS Code: Cannot find module "myimage.png"Typescript + VS Code:找不到模块“myimage.png”
【发布时间】:2019-08-08 23:39:58
【问题描述】:

我想从项目中的资产目录中导入图像。 它工作正常,但是,VS Code 抱怨说:

Cannot find module '../../../shared/assets/images/logo.png'.ts(2307)

这些是我的类型定义:

declare module '*.png';
declare module '*.jpg';
declare module '*.json';
declare module '*.svg';

我该如何解决这个问题?

【问题讨论】:

    标签: reactjs image typescript webpack import


    【解决方案1】:

    似乎没有加载包含类型定义的文件。

    修复

    • 确保包含文件(例如,匹配 tsconfig.json 中的 include
    • 重启 vscode

    【讨论】:

      猜你喜欢
      • 2015-10-11
      • 1970-01-01
      • 2016-09-12
      • 2019-09-29
      • 2019-05-06
      • 2020-08-08
      • 1970-01-01
      • 2016-02-25
      • 2019-08-16
      相关资源
      最近更新 更多