vue项目中应用elementUI的步骤条+折叠面板,达到如图效果

本文介绍如何在Vue项目中结合ElementUI,实现点击步骤条展开相应内容的功能。通过JavaScript控制步骤条和折叠面板的长度动态变化,步骤条与折叠面板的div采用左浮动布局,实现交互式的展示效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这里写图片描述

效果就是点击某个步骤就可以展开对应的内容.步骤条和折叠面板长度也会动态改变
都是通过元素js来改变长度.
先定义一个步骤条

<div style="width:130px;margin-top:20px;float:left">
  <el-steps :space="200" direction="vertical" :active="step" process-status="process" finish-status="wait">
      <el-step @click.native="on_click(1)" title="xxx" id="one"></el-step>
      <el-step @click.native="on_click(2)" title="xx" id="two"></el-step>
      <el-step @click.native="on_click(3)" title="xx" id="three"></el-step>
</el-steps>
</div>

再来个折叠面板,步骤条和折叠面板的div放在一个大的div中,这两个div设置为左浮动float=”left”

<div
### 实现带有进度条的折叠面板标题 为了实现在折叠面板(Accordion)组件中包含进度条的标题,可以考虑扩展现有的 `SimpleAccordion` 组件并引入一个新的子组件来表示带进度条的标题。这可以通过组合 HTML 和 CSS 来完成,并利用 Vue.js 的动态绑定特性。 #### 修改后的模板结构 ```html <template> <div class="simple-accordion"> <!-- 新增 ProgressTitle 组件 --> <progress-title :percentage="titleProgress"></progress-title> <slot></slot> </div> </template> <!-- 进度条标题组件定义 --> <script setup> import { defineComponent } from 'vue'; export default defineComponent({ props: { percentage: Number, }, }); </script> <template id="progress-title-template"> <h3 class="progress-title"> {{ titleText }} <span class="progress-bar-container"> <span class="progress-bar" :style="{ width: `${percentage}%` }"></span> </span> </h3> </template> ``` 上述代码展示了如何创建一个名为 `ProgressTitle` 的新组件用于显示带有进度指示器的标题[^1]。通过传递给该组件的一个百分比属性 (`percentage`) 控制进度条宽度。 #### 添加样式支持 对于 `.progress-title`, `.progress-bar-container`, 及`.progress-bar` 类名下的元素应用适当CSS样式: ```css .progress-title .progress-bar-container { display: inline-block; margin-left: 5px; } .progress-bar { height: 8px; background-color: green; transition: all ease-in-out 0.3s; } ``` 此部分负责设置视觉效果以及平滑过渡动画。 #### 数据驱动更新逻辑 为了让进度条能够响应数据变化而自动调整,在父级 accordion 组件内部维护状态变量 `titleProgress` 并将其作为 prop 下发至 progress-title 子组件: ```javascript data() { return { titleProgress: 75, // 初始值设为75% }; }, methods: { updateProgress(newPercentage) { this.titleProgress = newPercentage; } } ``` 这样就可以根据业务场景调用 `updateProgress()` 函数改变进度数值了。
评论 15
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值