vue 配置了 alias,如:1
2
3
4
5
6chainWebpack: config => {
config.resolve.alias.set('vue$', 'vue/dist/vue.esm.js')
config.resolve.alias.set('@img', path.resolve(__dirname, 'src/assets/images'))
config.resolve.alias.set('@js', path.resolve(__dirname, 'src/assets/js'))
...
}
这样在 import XXX from "@js/xxx"
后,没有代码提示了
在根目录新建 jsconfig.json
,内容:1
2
3
4
5
6
7
8
9
10
11{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@img/*": ["src/assets/images/*"],
"@js/*": ["src/assets/js/*"],
...
}
},
"exclude": ["node_modules", "dist"]
}
用于配置 alias 指向的目录,然后 重启 vscode!