- 在vite.config.js文件下添加配置,没有这文件的新建一个
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from "path";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
resolve: {
alias: {
'@': resolve(__dirname, './src')
}
}
})
- 在jsconfig.json文件添加配置,不加也能用就是没有提示鼠标没法点击跳转到对应文件
{
"compilerOptions": {
"target": "ES6",
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"paths": {
"@/*": [
"src/*"
]
}
},
"exclude": [
"node_modules"
]
}