1. インストールの依存関係
npm install path --save
2、プラグインをインストールするPath Intellisense
3. 設定 - 検索パス-インテリセンス - settings.json で編集
構成:
{
"path-intellisense.mappings": {
"@": "${workspaceRoot}/src"
},
}
四、vite.config.js
でのエイリアス設定。@
シンボルがsrc
ディレクトリに正しくマップされていることを確認してください
import { defineConfig } from 'vite';
import path from 'path';
export default defineConfig({
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
// 其他配置...
});
5. プロジェクトのルート ディレクトリに、次の内容を含む jsconfig.json ファイルを作成します。
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"allowSyntheticDefaultImports": true,
"baseUrl": "./",
"paths": {
"@/*": [
"src/*"
]
}
},
"exclude": [
"node_modules"
]
}