按照文档进行安装,第二个插件是样式的插件
npm i unplugin-vue-components unplugin-element-plus -D
vite.config.js
import ElementPlus from 'unplugin-element-plus/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
export default defineConfig({
plugins: [
ElementPlus({
importStyle: 'sass',
useSource: true
}),
Components({
resolvers: [ElementPlusResolver()]
})
]
})
在页面上直接使用就可以了
<el-button type="primary" round>Primary</el-button>
网友评论