它是非常基本的问题,但不起作用......我创建了新的 create-react-app 并为亲属路径安装了 craco,但 vsCode 在导入期间仍然给我错误。
craco.config.js
const path = require('path');
module.exports = {
webpack: {
alias: {
'@': path.resolve(__dirname, 'src/'),
'@components/*': path.resolve(__dirname, 'src/components'),
'@views/*': path.resolve(__dirname, 'src/views')
}
},
jest: {
configure: {
moduleNameMapper: {
'^@(.*)$': '<rootDir>/src$1'
}
}
}
};
tsconfig.json
[{
"compilerOptions": {
"baseUrl": "./",
"target": "es5",
"lib": \[
"dom",
"dom.iterable",
"esnext"
\],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": \[
"src"
\],
"paths": {
"@components/*": \["src/components/*"\],
"@views/*": \["src/views/*"\]
}
}][1]
我认为我做的一切都是正确的......但它仍然无法正常工作。请帮助[1]:https ://i.stack.imgur.com/8I7CB.png