导入依赖模块是标红
1. 在 tsconfig.json 文件中,将 "moduleResolution" 设置成 "node"
"compilerOptions": {
"moduleResolution": "node",
}
2. 设置路径 path
"compilerOptions": {
"moduleResolution": "node",
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},
完整设置
"compilerOptions": {
"jsx": "preserve",
"moduleResolution": "node",
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
}
},