问题:
In typescript(*.tsx)
files I cannot import svg file with this statement:在typescript(*.tsx)
文件中,我无法使用以下语句导入 svg 文件:
import logo from './logo.svg';
Transpiler says: [ts] cannot find module './logo.svg'.
Transpiler 说: [ts] cannot find module './logo.svg'.
My svg file is just <svg>...</svg>
.我的 svg 文件只是<svg>...</svg>
。
But in .js
file I'm able to import it without any issues with exact the same import statement.但是在.js
文件中,我可以使用完全相同的导入语句导入它而不会出现任何问题。 I suppose it has something to do with type of svg file which must be set somehow for ts transpiler.我想它与 svg 文件的类型有关,必须以某种方式为 ts 转译器设置。
Could you please share how to make this work in ts files?你能分享一下如何在 ts 文件中进行这项工作吗?
解决方案:
参考一: https://en.stackoom.com/question/31cya参考二: https://stackoom.com/question/31cya