0%

vue 项目配置

vite.config.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// https://vite.dev/config/
export default defineConfig({
plugins: [
vue(),
vueDevTools(),
// 使用 ele plus 的自动导入
AutoImport({
resolvers: [ElementPlusResolver()]
}),
// 使用 ele plus 的自动导入
Components({
resolvers: [ElementPlusResolver()]
})
],
resolve: {
// 在 import 中使用 @ 代替 src
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
},
// 使 import @/button 的时候导入 @/button/index.vue
extensions: ['.vue', '.js', '/index.js', '/index.vue']
},
// 允许内网访问
server: { host: true }
})

jsconfig.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
"compilerOptions": {
"remark": "使vscode识别 import 中的 @",
"paths": {
"@/*": [
"./src/*"
]
}
},
"exclude": [
"node_modules",
"dist"
],
}