Element Plus uses on-demand introduction to greatly reduce the size of the packaged files
Automatically generate the components.d.ts file, and introduce the Element Plus component into the file
##2 Preparation work
# 选择一个你喜欢的包管理器 # NPM $ npm install element-plus --save # Yarn $ yarn add element-plus # pnpm $ pnpm install element-plus
3 Import on demand
3.2 Modify vite .config.ts file$ pnpm i unplugin-auto-import unplugin-vue-components unplugin-icons -DCopy after login
4 Others
Note, -ep - It is configured in the vite.config.ts file and must be consistent4.2 Icon usage// 示例 import { ElMessage } from 'element-plus' import 'element-plus/es/components/message/style/css'Copy after login
<!-- 直接使用 --> <i-ep-menu /> <!-- 嵌套使用 --> <el-icon><i-ep-menu /></el-icon>Copy after loginThe above is the detailed content of How to use Vue3 and Element Plus to implement automatic import. For more information, please follow other related articles on the PHP Chinese website!