reacttypescript@别名的使用
- 人工智能
- 2025-08-14 11:30:02

1、config/webpack.config.js中找到alias,添加"@": path.resolve(__dirname,'../src'),如下:
alias: { // Support React Native Web // .smashingmagazine /2016/08/a-glimpse-into-the-future-with-react-native-for-web/ "react-native": "react-native-web", // Allows for better profiling with ReactDevTools ...(isEnvProductionProfile && { "react-dom$": "react-dom/profiling", "scheduler/tracing": "scheduler/tracing-profiling", }), ...(modules.webpackAliases || {}), "@": path.resolve(__dirname,'../src') },2、tsconfg.json中配置,新增"paths":{"@/*":["./src/*"]}
{ "compilerOptions": { "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", "paths": { "@/*": ["./src/*"] } }, "include": [ "src" ] }3、重启收工
reacttypescript@别名的使用由讯客互联人工智能栏目发布,感谢您对讯客互联的认可,以及对我们原创作品以及文章的青睐,非常欢迎各位朋友分享到个人网站或者朋友圈,但转载请说明文章出处“reacttypescript@别名的使用”