el-tabs和el-steps切换以及steps点击事件

news/2024/7/10 1:28:55 标签: vue

首先,还是百度了一下示例,但是这些人的效果都不太满意,并且还有bug,故而自己改造了一下代码。

<template>
  <div>
    <el-steps :active="active_index - 0" simple style="margin-top: 20px">
      <el-step
          v-for="(item,index) of stepParams"
          :key="index"
          :title="item.title"
          :icon="item.icon"
          :status="item.status"
          :class="stepSuc.includes(index) ? 'stepSuc':'stepErr'"
          @click.native="handleStep(index)"
      />
    </el-steps>
    <el-tabs :tab-position="'left'" v-model="active" style="height: 500px;" @tab-click="handleTabStep">
      <el-tab-pane label="步骤一" name="0">步骤一</el-tab-pane>
      <el-tab-pane label="步骤二" name="1">步骤二</el-tab-pane>
      <el-tab-pane label="步骤三" name="2">步骤三</el-tab-pane>
      <el-tab-pane label="步骤四" name="3">步骤四</el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
export default {
  name: "xxxxCompent",
  props: {
    parameter: {}
  },
  data() {
    return {
      // 步骤
      active_index: 0,
      active: '0',
      // 已选步骤
      stepSuc: [0],
      // 步骤参数
      stepParams: [
        {
          title: '步骤一',
          icon: 'el-icon-edit',
          status: 'process'
        },
        {
          title: '步骤二',
          icon: 'el-icon-upload',
          status: 'wait'
        },
        {
          title: '步骤三',
          icon: 'el-icon-picture',
          status: 'wait'
        },
        {
          title: '步骤四',
          icon: 'el-icon-circle-check',
          status: 'wait'
        },
      ],
    }
  },
  methods: {
    // 点击步骤条
    handleStep(val) {
      if (this.stepSuc.includes(val)) {
        this.active_index = val;
        this.active = val.toString();
      }
      this.handleStatus();
    },
    // 点击tab
    handleTabStep() {
      this.stepSuc = [];
      this.active_index = parseInt(this.active);
      let temp = this.active_index;
      while (temp !== 0) {
        this.stepSuc.push(--temp);
      }
      this.handleStatus();
    },
    handleStatus(){
      switch (this.active_index){
        case 0:
          this.stepParams[0].status = 'process';
          this.stepParams[1].status = 'wait';
          this.stepParams[2].status = 'wait';
          this.stepParams[3].status = 'wait';
          break;
        case 1:
          this.stepParams[0].status = 'finish';
          this.stepParams[1].status = 'process';
          this.stepParams[2].status = 'wait';
          this.stepParams[3].status = 'wait';
          break;
        case 2:
          this.stepParams[0].status = 'success';
          this.stepParams[1].status = 'finish';
          this.stepParams[2].status = 'process';
          this.stepParams[3].status = 'wait';
          break;
        case 3:
          this.stepParams[0].status = 'success';
          this.stepParams[1].status = 'success';
          this.stepParams[2].status = 'finish';
          this.stepParams[3].status = 'process';
          break;
        default:
          this.stepParams[0].status = 'process';
          this.stepParams[1].status = 'wait';
          this.stepParams[2].status = 'wait';
          this.stepParams[3].status = 'wait';
          break;
      }
    },
    // 组件点击上一步
    handleLastStep() {
      if (--this.active_index === 0) {
        this.active_index = 0
      }
    },
    // 组件点击下一步
    handleNextStep() {
      this.stepSuc.push(++this.active_index)
    },
  },
}
</script>

<style scoped>
.stepSuc :hover {
  cursor: pointer;
}

.stepErr :hover {
  cursor: not-allowed;
}

</style>

在这里插入图片描述
参照连接:https://blog.csdn.net/weixin_44769310/article/details/104655670
https://blog.csdn.net/weixin_42614080/article/details/104393335


http://www.niftyadmin.cn/n/1638465.html

相关文章

el-form表单el-input、el-select只读设置,去掉(删掉)边框线,完美替换整个HTML

前言​ 欢迎大家来到我的博客&#xff0c;请各位看客们点赞、收藏、关注三连&#xff01; 欢迎大家关注我的知识库&#xff0c;全栈进阶之路语雀 你的关注就是我前进的动力&#xff01; CSDN专注于问题解决的博客记录&#xff0c;语雀专注于知识的收集与汇总&#xff0c;包…

使用wifi网卡笔记5---AP模式

使用WIFI网卡的AP功能 1、下载源码 hostapd: http://w1.fi/hostapd/ 2、编译、安装&#xff08;hostapd依赖于libnl库&#xff0c;需要编译、安装此库&#xff09; tar xzf hostapd-2.0.tar.gz cd hostapd-2.0/ cd hostapd/ cp defconfig .config 修改.config, 加一行: CONFIG_…

VUE解决Cannot read property ‘length‘ of undefined(发生原因以及解决思路)

这个错误是什么 某个数组找不到值&#xff0c;有一个地方进行了强行赋值 为什么会报这个错误 因为你在使用数组时&#xff0c;有一些v-for循环渲染&#xff0c;它不是拿着data创建的 [] 空数组去遍历&#xff0c;而是在某个地方你去获取下拉框的数据&#xff0c;或者获取dat…

运行地址、链接地址、加载地址、存储地址

1、概念理解 运行地址<--->链接地址&#xff1a;他们两个是等价的&#xff0c;只是两种不同的说法。 加载地址<--->存储地址&#xff1a;他们两个是等价的&#xff0c;也是两种不同的说法。 运行地址&#xff1a;程序在SRAM、SDRAM中执行时的地址。就是执行这条指…

多层(嵌套)for循环中list add新增map或者object,内容和地址都是一个(被覆盖问题)

首先呢&#xff0c;我直接拿那些人博客的例子。 public static void main(String[] args) {int [] arrs{1,2,3,4};String[] sheets {"我","是"}ArrayList<String> strings new ArrayList<>();for (String sheet : sheets){for (int i: arrs…

汇编调用C函数要设置栈的原因

转载来源http://www.cnblogs.com/xmphoenix/archive/2012/04/28/2475399.html 一.栈的整体作用 (1)保存现场/上下文 (2)传递参数:汇编代码调用c函数时&#xff0c;需传递参数 (3)保存临时变量:包括函数的非静态局部变量以及编译器自动生成的其他临时变量。二.为什么汇编代码…

linux scp 【全新思路解决】出现Permission denied问题

前言​ 欢迎大家来到我的博客&#xff0c;请各位看客们点赞、收藏、关注三连&#xff01; 欢迎大家关注我的知识库&#xff0c;Java之从零开始语雀 你的关注就是我前进的动力&#xff01; CSDN专注于问题解决的博客记录&#xff0c;语雀专注于知识的收集与汇总&#xff0c;…

el-dialog打开与关闭的几种方式

前言​ 欢迎大家来到我的博客&#xff0c;请各位看客们点赞、收藏、关注三连&#xff01; 欢迎大家关注我的知识库&#xff0c;全栈进阶之路语雀 你的关注就是我前进的动力&#xff01; CSDN专注于问题解决的博客记录&#xff0c;语雀专注于知识的收集与汇总&#xff0c;包…