赞
踩
目录
- npm install element-plus
- yarn add element-plus
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')
npm install -D unplugin-vue-components unplugin-auto-import
vite.config.ts
- import { defineConfig } from 'vite'
- import vue from '@vitejs/plugin-vue'
- import AutoImport from 'unplugin-auto-import/vite'
- import Components from 'unplugin-vue-components/vite'
- import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
-
- export default defineConfig({
- // ...
- plugins: [
- vue(),
- AutoImport({
- resolvers: [ElementPlusResolver()],
- }),
- Components({
- resolvers: [ElementPlusResolver()],
- }),
- ],
- })
webpack.config.js
- const AutoImport = require('unplugin-auto-import/webpack')
- const Components = require('unplugin-vue-components/webpack')
- const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')
-
- module.exports = {
- // ...
- plugins: [
- AutoImport({
- resolvers: [ElementPlusResolver()],
- }),
- Components({
- resolvers: [ElementPlusResolver()],
- }),
- ],
- }
- 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')
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。