import { createApp } from ‘vue‘
import App from ‘./App.vue‘
import ‘element-plus/lib/theme-chalk/index.css‘
import { ElButton, ElSelect, ElLoading, ElNotification} from ‘element-plus‘;
const components = [
ElButton, ElSelect
]
const plugins = [ElLoading, ElNotification]
const app = createApp(App)
components.forEach((component) => {
app.component(component.name, component)
})
plugins.forEach((plugin) => app.use(plugin))
app.mount(‘#app‘)
----------------------------------------------------
import { defineConfig } from ‘vite‘
import vue from ‘@vitejs/plugin-vue‘
import styleImport from ‘vite-plugin-style-import‘
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue(),
styleImport({
libs: [{
libraryName: ‘element-plus‘,
resolveStyle: (name) => {
name = name.substr(3) 改为substr即可解决
return `element-plus/packages/theme-chalk/src/${name}.scss`;
},
resolveComponent: (name) => {
return `element-plus/lib/${name}`;
},
}]
})]
})