Vue前端封装一个任务条的组件进行使用

任务条

样式

 代码

父组件

<articleSteps :tabs="tabs" :tabs-active-name="tabsActiveName" />

<div class="drawer__footer">
      <el-button v-if="tabsActiveName === 1 || tabsActiveName === 2" @click="backClick">返回</el-button>
      <el-button v-if="tabsActiveName === 1" :disabled="loadding" type="primary" size="mini" @click="goNext">
        下一步
      </el-button>
      <el-button v-if="tabsActiveName === 2 " type="primary" size="mini" @click="tabsActiveName--">上一步</el-button>
    </div>

export default{
    
    methods:{
        // 下一步
        goNext() {
          this.tabsActiveName++
        },

         backClick() {
              if (this.$route.query.type === '1') {
                this.$router.go(-1)
              } else if (this.$route.query.pageType === '企业端') {
                this.$router.push({
                  name: 'assetPoolTransactionQueryGroup',
                  query: {
                    activeName: 'second'
                  }
                })
              } else if (this.$route.query.pageType === '集团') {
                this.$router.push({
                  name: 'assetPoolTransactionQueryGroup',
                  query: {
                    activeName: 'second'
                  }
                })
              } else { // 运营端
                this.$router.push({
                  name: 'operationAssetPoolTransactionQuery',
                  query: {
                    activeName: 'second'
                  }
                })
      }

    }


}

子组件

<template>
  <div>
    <div class="tabs_mune">
      <div
        v-for="(item, index) in tabs"
        :key="index"
        :class="tabsActiveName >= index + 1 ? 'tabs_active' : ''"
        :style="'width:' + 100 / tabs.length + '%'"
      >
        <span>{{ item }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    tabsActiveName: {
      type: Number,
      default: () => {
        return 1
      }
    },
    tabs: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {}
  }
}
</script>

<style lang="scss" scoped>
.tabs_mune {
  background: #fafafa;
  height: 30px;
  line-height: 30px;
  margin-bottom: 20px;
  div {
    // text-align: center;
    // display: inline-block;
    &:first-child {
      padding-left: 8%;
      display: inline-block;
    }
    &:nth-child(2) {
      padding-left: 13%;
      display: inline-block;
    }
    &:nth-child(3) {
      padding-left: 18%;
      display: inline-block;
    }
    span {
      color: #000;
      opacity: 0.65;
    }
  }
  .tabs_active {
    background-color: #1890ff;
    position: relative;
    span {
      color: #fff;
      opacity: 1;
    }
    &:after {
      content: "";
      position: absolute;
      top: 0px;
      left: 100%;
      border-top: 15px solid transparent;
      border-bottom: 15px solid transparent;
      border-left: 13px solid #1890ff;
    }
  }
}
</style>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值