Failed to resolve import "element-plus/es/el-sub-menu" from "src\components\
在vite+ts+elementplus中自动导入遇到的问题
总是报Failed to resolve import "element-plus/es/el-sub-menu" from "src\components\
我的解决办法
- 把配置的顺序调一下
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import * as path from 'path';
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
//配置自动导入element start
AutoImport({
resolvers: [ElementPlusResolver()],
}),
Components({
resolvers: [ElementPlusResolver()],
}),
//配置自动导入element end
vue(),
],
//配置@符
resolve:{
alias:{
"@":path.join(__dirname,"src"),
"#":path.join(__dirname,"types")
}
}
})