一、让vite做路径解析
1、安装第三方Node包
npm i @types/node -D
2、配置别名路径
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(__dirname,'./src')
}
}
})
二、让vscode做智能路径提示
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},