๐ Quick Start โ
Welcome to the Element Plus Study Guide! This guide will help you quickly set up your development environment and begin your Element Plus learning journey.
๐ Learning Roadmap โ
graph TD
A[Environment Preparation] --> B[Project Initialization]
B --> C[Element Plus Installation & Configuration]
C --> D[Design Principles Learning]
D --> E[First Component Practice]
E --> F[Project Structure Optimization]
F --> G[Begin Systematic Learning]
๐ฏ Learning Objectives โ
- โ Set up a modern Vue 3 + Element Plus development environment
- โ Understand Element Plus core design principles
- โ Master basic component usage methods
- โ Create your first complete component demo page
- โ Establish good code standards and project structure
๐ ๏ธ Environment Preparation โ
System Requirements โ
Tool | Version Requirement | Recommended Version | Description |
---|---|---|---|
Node.js | >= 16.0.0 | 18.x LTS | JavaScript runtime environment |
npm | >= 7.0.0 | Latest version | Package manager |
Vue | >= 3.3.0 | 3.5.x | Frontend framework |
Element Plus | >= 2.4.0 | 2.10.x | UI component library |
Recommended Development Tools โ
- IDE: VS Code + Volar extension
- Browser: Chrome/Edge (with Vue DevTools support)
- Package Manager: pnpm (recommended) / yarn / npm
๐๏ธ Project Initialization โ
Option 1: Using This Project Template (Recommended) โ
# Clone the project
git clone https://github.com/shingle666/element-plus-study.git
cd element-plus-study
# Install dependencies
npm install
# Or use pnpm (recommended)
pnpm install
# Start development server
npm run dev
# Start documentation server
npm run docs:dev
Option 2: Create Project from Scratch โ
# Create Vue 3 project with Vite
npm create vue@latest my-element-plus-app
cd my-element-plus-app
# Install dependencies
npm install
# Install Element Plus
npm install element-plus @element-plus/icons-vue
# Install auto-import plugins (optional but recommended)
npm install -D unplugin-vue-components unplugin-auto-import
โ๏ธ Element Plus Configuration โ
Full Import (Suitable for Learning Phase) โ
Configure in src/main.js
:
import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
const app = createApp(App)
// Register all icons
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component)
}
app.use(ElementPlus)
app.mount('#app')
On-demand Import (Recommended for Production) โ
Configure in vite.config.js
:
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()],
}),
],
})
๐จ Deep Understanding of Design Principles โ
Element Plus follows four core design principles, understanding these principles is crucial for using components correctly:
๐ Consistency โ
Consistent with Real Life
- Follow users' cognitive habits
- Use common interaction patterns
- Maintain consistency in language expression
Consistent Interface Elements
- Unified visual style
- Consistent interaction behavior
- Standardized layout structure
๐ฌ Feedback โ
Control Feedback
- Visual feedback for button clicks
- Real-time form validation prompts
- Clear loading state display
Page Feedback
- Clear display of operation results
- Accurate error message communication
- Timely success state feedback
โก Efficiency โ
Simplified Process
- Reduce unnecessary operation steps
- Provide shortcut operation methods
- Smart default value settings
Clear and Explicit
- Concise text expression
- Intuitive icon design
- Clear operation guidance
๐๏ธ Controllability โ
User Decision
- Provide operation suggestions rather than forcing
- Important operations require confirmation
- Preserve user choice
Controllable Results
- Support undo operations
- Provide fallback mechanisms
- Allow process interruption
๐ฏ First Component Practice: Button โ
Let's practice using Element Plus with the Button component:
Create Demo Page โ
Create ButtonDemo.vue
in the src/views/
directory:
<template>
<div class="button-demo-container">
<h2>๐ฏ Button Component Learning Practice</h2>
<!-- Basic Buttons -->
<section class="demo-section">
<h3>Basic Buttons</h3>
<div class="button-group">
<el-button>Default Button</el-button>
<el-button type="primary">Primary Button</el-button>
<el-button type="success">Success Button</el-button>
<el-button type="info">Info Button</el-button>
<el-button type="warning">Warning Button</el-button>
<el-button type="danger">Danger Button</el-button>
</div>
</section>
<!-- Plain Buttons -->
<section class="demo-section">
<h3>Plain Buttons</h3>
<div class="button-group">
<el-button plain>Plain Button</el-button>
<el-button type="primary" plain>Primary Button</el-button>
<el-button type="success" plain>Success Button</el-button>
<el-button type="info" plain>Info Button</el-button>
<el-button type="warning" plain>Warning Button</el-button>
<el-button type="danger" plain>Danger Button</el-button>
</div>
</section>
<!-- Button Sizes -->
<section class="demo-section">
<h3>Button Sizes</h3>
<div class="button-group">
<el-button size="large">Large Button</el-button>
<el-button>Default Button</el-button>
<el-button size="small">Small Button</el-button>
</div>
</section>
<!-- Button States -->
<section class="demo-section">
<h3>Button States</h3>
<div class="button-group">
<el-button :loading="loading" @click="handleLoading">Loading Button</el-button>
<el-button disabled>Disabled Button</el-button>
<el-button type="primary" :icon="Search">Search</el-button>
<el-button type="primary" circle :icon="Plus" />
</div>
</section>
<!-- Interaction Demo -->
<section class="demo-section">
<h3>Interaction Demo</h3>
<div class="button-group">
<el-button type="success" @click="showMessage('success')">Success Message</el-button>
<el-button type="warning" @click="showMessage('warning')">Warning Message</el-button>
<el-button type="danger" @click="showMessage('error')">Error Message</el-button>
</div>
</section>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { ElMessage } from 'element-plus'
import { Search, Plus } from '@element-plus/icons-vue'
const loading = ref(false)
const handleLoading = () => {
loading.value = true
setTimeout(() => {
loading.value = false
ElMessage.success('Loading complete!')
}, 2000)
}
const showMessage = (type) => {
const messages = {
success: 'Operation successful!',
warning: 'Please note!',
error: 'Operation failed!'
}
ElMessage[type](messages[type])
}
</script>
<style scoped>
.button-demo-container {
padding: 20px;
max-width: 1200px;
margin: 0 auto;
}
.demo-section {
margin-bottom: 40px;
padding: 20px;
border: 1px solid #e4e7ed;
border-radius: 8px;
background-color: #fafafa;
}
.demo-section h3 {
margin-bottom: 16px;
color: #303133;
font-size: 18px;
}
.button-group {
display: flex;
gap: 12px;
flex-wrap: wrap;
align-items: center;
}
.button-group .el-button {
margin: 0;
}
</style>
Router Configuration โ
Add route in src/router/index.js
:
import { createRouter, createWebHistory } from 'vue-router'
import ButtonDemo from '../views/ButtonDemo.vue'
const routes = [
{
path: '/button-demo',
name: 'ButtonDemo',
component: ButtonDemo
}
]
const router = createRouter({
history: createWebHistory(),
routes
})
export default router
โ Learning Checklist โ
Environment Setup โ
- [ ] โ Node.js version >= 16.0.0
- [ ] โ Successfully created Vue 3 project
- [ ] โ Element Plus installed and configured
- [ ] โ Development server started normally
- [ ] โ Browser can access the project normally
Design Principles Understanding โ
- [ ] ๐ Understand the importance of consistency principle
- [ ] ๐ Master application scenarios of feedback principle
- [ ] ๐ Learn practical methods of efficiency principle
- [ ] ๐ Clarify design ideas of controllability principle
Component Practice โ
- [ ] ๐ฏ Create Button component demo page
- [ ] ๐ฏ Implement different types of buttons
- [ ] ๐ฏ Master button size and state control
- [ ] ๐ฏ Complete interaction function demonstration
- [ ] ๐ฏ Understand component API design ideas
Code Quality โ
- [ ] ๐ป Clear and reasonable code structure
- [ ] ๐ป Follow Vue 3 best practices
- [ ] ๐ป Unified style standards
- [ ] ๐ป Complete and accurate comments
๐ Learning Resources โ
Official Documentation โ
- ๐ Element Plus Official Website - Most authoritative component documentation
- ๐จ Design Guide - Deep understanding of design principles
- ๐ง Button Component Documentation - Detailed API description
- ๐ Vue 3 Official Documentation - Vue 3 basic knowledge
Development Tools โ
- ๐ ๏ธ Vue DevTools - Vue developer tools
- ๐ฏ Volar - VS Code Vue plugin
- ๐ฆ Element Plus Playground - Online code demonstration
Community Resources โ
- ๐ฌ Element Plus GitHub - Source code and issue discussions
- ๐ Vue 3 + Element Plus Tutorial - Video tutorials
- ๐ Medium Element Plus Articles - Technical articles
โ ๏ธ Important Notes โ
Environment Requirements โ
- โ Node.js Version: >= 16.0.0 (18.x LTS recommended)
- โ Package Manager: pnpm > yarn > npm recommended
- โ Browser: Modern browsers supporting ES2018+
Best Practices โ
- ๐ฏ On-demand Import: Recommended for production to reduce package size
- ๐ง TypeScript: Recommended for better development experience
- ๐ฑ Responsive Design: Pay attention to mobile adaptation and responsive layout
- ๐จ Theme Customization: Learn to use CSS variables for theme customization
Common Issues โ
๐ค What if component styles don't work?
- Check if Element Plus CSS file is correctly imported
- Confirm if the component is correctly registered
- Check for style conflicts or overrides
๐ค On-demand import configuration failed?
- Confirm compatibility of
unplugin-vue-components
andunplugin-auto-import
versions - Check if Vite configuration file syntax is correct
- Restart development server
๐ค Icons not displaying properly?
- Confirm
@element-plus/icons-vue
is installed - Check if icon components are correctly imported and registered
- Confirm icon names are spelled correctly
๐ Next Learning Plan โ
Congratulations on completing the Element Plus quick start! Here's a suggested path to continue learning:
๐ Week 1: Master Basic Components โ
- ๐ Design Principles & Basic Concepts
- ๐งฉ Button - Deep learning of button component
- ๐จ Layout - Master page layout
- ๐ Icon - Icon system usage
๐ Week 2: Form Component Practice โ
๐ Week 3: Data Display Components โ
๐ Advanced Learning โ
- ๐๏ธ Architecture Design - Deep understanding of component library architecture
- โก Performance Optimization - Master performance optimization techniques
- ๐จ Theme Customization - Learn theme system
- ๐ผ Project Practice - Comprehensive project development
๐ Learning Record โ
Learning Date: ___________
Completion Status: ___________
Learning Duration: ___________
๐ Learning Notes โ
Record your learning insights and important knowledge points here:
1.
2.
3.
โ Problems Encountered โ
Record problems encountered during learning:
Problem 1:
Solution:
Problem 2:
Solution:
๐ก Gains and Insights โ
Record your gains and understanding of Element Plus:
๐ Congratulations on completing the quick start!
๐ View Complete Study Guide | ๐ Return to Home | ๐ View Changelog