Skip to main content

๐Ÿ‘ฉโ€๐Ÿ’ป element ui plus ๅปบ็ฝฎ

็‰ˆๆœฌโ€‹

  • vue: 3.2.41
  • vite: 3.2.0
  • typescript: 4.6.4
  • element-plus: 2.3.12

ๅฎ‰่ฃโ€‹

ๅฎ‰่ฃ element-plusโ€‹

yarn add element-plus

ๅฎ‰่ฃๅฅ—ไปถโ€‹

unplugin-vue-components ๅ’Œ unplugin-auto-import

ๅฏไปฅๅœจ้œ€่ฆๆ™‚ๅœจๅฐŽๅ…ฅUI๏ผŒ้™ไฝŽๅฐˆๆกˆ็š„ๅคงๅฐ

yarn add unplugin-vue-components unplugin-auto-import

ๆ–ผ vite.config.ts ๅŠ ๅ…ฅ่จญๅฎš

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 vue from '@vitejs/plugin-vue'


export default defineConfig({
plugins: [vue(),
AutoImport({
resolvers: [ElementPlusResolver()],
}),
Components({
resolvers: [ElementPlusResolver()],
}),]
})

ๅŠ ๅ…ฅๅˆฐๅ…จๅŸŸโ€‹

import { createApp } from "vue";
import { createPinia } from "pinia";
import ElementPlus from 'element-plus'
import router from "./router/index";
import App from "./App.vue";
import './style.css'

const app = createApp(App);

app.use(router).use(createPinia()).use(ElementPlus, { size: 'small', zIndex: 3000 }).mount("#app");