vue3.4.29引入element UI
NPM
- npm install element-plus --save
2.main.js配置
import { createApp } from ‘vue’
import ElementPlus from ‘element-plus’ //全局引入
import ‘element-plus/dist/index.css’
import App from ‘./App.vue’
const app = createApp(App)
app.use(ElementPlus)
app.mount(‘#app’)
3.vite.config.js配置
import { defineConfig } from ‘vite’
import AutoImport from ‘unplugin-auto-import/vite’
import Components from ‘unplugin-vue-components/vite’
import { ElementPlusResolver } from ‘unplugin-vue-components/resolvers’
// import { defineConfig } from “vite”;
import vue from “@vitejs/plugin-vue”;
export default defineConfig({
// …
plugins: [
// …
AutoImport({
resolvers: [ElementPlusResolver()],
}),
Components({
resolvers: [ElementPlusResolver()],
}),
[vue()],
],
})
4.测试
Primary
Success
结果截图: