我已经在 tsconfig.json
中配置了 paths
。除了导入 svg
和 png
等 Assets 文件外,一切正常。
这是我在 tsconfig.json
中的路径
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@components/*": ["./src/components/*"],
"@components": ["./src/components"],
"@app/*": ["./src/app/*"],
"static": ["static/*"]
},
...
}
我是这样导入的:
import imageAdd from "static/images/image-add.png";
import circleIcon from "static/icons/circle-close.svg"
最佳答案
将 "static": ["static/*"]
替换为 "static/*": ["static/*"]
关于javascript - 如何在 TypeScript 中为图像添加路径别名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72691551/