Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Element UI (Vue 2) vs Element Plus (Vue 3): Working with the Divider Component

Tech 2

Presentation-Focused Divider Behavior for Both Ecosystems

Both Vue 2’s Element UI and Vue 3’s Element Plus feature a el-divider component as a visual separator. Since it’s designed solely for layout clarity, neither version exposes events or public methods for external interaction. Core functionality relies almost entirely on prop configuration, making cross-version migration straightforward.


Vue 2 + Element UI Implementation

In Vue 2 projects, el-divider leverages a small set of intuitive props to adjust orientation and layout integration.

Key Props

  • orientation: Controls divider axis, accepts horizontal (default) or vertical.

Practical Example

<template>
  <div class="divider-demo-v2">
    <!-- Horizontal separator between content blocks -->
    <div class="text-block">Header Content</div>
    <el-divider />
    <div class="text-block">Main Body Preview</div>

    <!-- Vertical separator between inline elements -->
    <div class="inline-group">
      <span>Profile</span>
      <el-divider orientation="vertical" />
      <span>Settings</span>
      <el-divider orientation="vertical" />
      <span>Help</span>
    </div>
  </div>
</template>

<style scoped>
.divider-demo-v2 .text-block {
  padding: 12px 0;
}
.divider-demo-v2 .inline-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
</style>

Note: Element UI must be registered globally in main.js for SFC access.


Vue 3 + Element Plus Implementation

Element Plus retains the same core prop structure for el-divider to minimize breaking changes, with minor internal styling updates for Vue 3’s reactivity system alignment.

Key Props

  • orientation: Identical behavior to Vue 2’s version, defaulting to horizontal with vertical as an alternative.

Practical Example

<template>
  <div class="divider-demo-v3">
    <!-- Stacked horizontal dividers -->
    <div class="card-header">Dashboard Overview</div>
    <el-divider />
    <div class="card-body">Live metrics will render here</div>
    <el-divider />
    <div class="card-footer">Last updated 2 seconds ago</div>

    <!-- Vertical divider with adjusted spacing container -->
    <div class="status-badge-row">
      <span class="badge success">Online</span>
      <el-divider orientation="vertical" />
      <span class="badge warning">Limited Bandwidth</span>
    </div>
  </div>
</template>

<style scoped>
.divider-demo-v3 {
  max-width: 450px;
  margin: 0 auto;
}
.divider-demo-v3 .card-header,
.divider-demo-v3 .card-body,
.divider-demo-v3 .card-footer {
  padding: 10px 16px;
}
.divider-demo-v3 .status-badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
}
.divider-demo-v3 .badge {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}
.divider-demo-v3 .success {
  background: #e6f7ff;
  color: #1890ff;
}
.divider-demo-v3 .warning {
  background: #fff7e6;
  color: #faad14;
}
</style>

Note: Global Elemant Plus registration is typically handled in main.js for Vue 3 applications.

Tags: Vue 2

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.