问题:找不到模块“@/…”或其相应的类型声明
解决方法:
tsconfig.json 中添加配置
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "Node",
"strict": true,
"jsx": "preserve",
"sourceMap": true,
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true,
//添加配置 start
"baseUrl": "./",// 解析非相对模块的基础地址,默认是当前目录
"paths": {
// 路径映射,相对于baseUrl
"@/*":["src/*"]
}
//添加配置 end
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
}