【_ 記 】vue 三角形步骤条 CSS样式+页面引用

56 篇文章 0 订阅
16 篇文章 0 订阅

vue 三角形步骤条展示:在这里插入图片描述

CSS样式 页面源码

<template>
    <ul class="triangle_step">
        <li :class="{cur:active>=index}" v-for="(item,index) in stepArr" :style="{width:width}">
            <span>{{item.title}}</span>
            <div v-if="index<stepArr.length-1" :class="active>=index?'jiaoActive':'jiao'"></div>
            <div class="interval"></div>
        </li>
    </ul>
</template>
<script>
    export default{
        props:{
            active:{
                default:0
            },
            stepArr:{
                default:[]
            },
            width:{
                default:'100%'
            }
        },
        watch:{
            active(a){
                if(a<=0){
                    this.$emit('update:active',0)
                    console.log('已经是最小值了'+a)
                }
                if(a>this.stepArr.length-1){
                    this.$emit('update:active',this.stepArr.length-1)
                    console.log('已经是最大值了'+a)
                }
            }
        },
        data(){
            return{

            }
        }
    }
</script>
<style scoped lang="scss">
    *{
        margin: 0;
        padding: 0;
        list-style: none;
        font-size: 12px;
    }
    .triangle_step{
        height: 40px;
        display: flex;
        justify-content: center;
        align-items: center;
        margin: 10px auto;
        li{
            height: 40px;
            background: #d7d8da;
            color:#666;
            text-align: center;
            line-height: 40px;
            /*width: 20%;*/
            /*flex-basis: 100%;*/
            position: relative;
        }
        li.cur{
            background: #E8514A;
            color:#fff;
        }
        /*三角形绘制*/
        .jiao{
            width: 0;
            height: 0;
            border-top: 20px solid transparent;/*高度一半*/
            border-left: 20px solid #d7d8da; /*调整宽度*/
            border-bottom: 20px solid transparent;/*高度一半*/
            position: absolute;
            right:-20px;/*跟宽度保持一致*/
            top:0;
            z-index: 9999;
        }
        .jiaoActive{
            width: 0;
            height: 0;
            border-top: 20px solid transparent;/*高度一半*/
            border-left: 20px solid #E8514A; /*调整宽度*/
            border-bottom: 20px solid transparent;/*高度一半*/
            position: absolute;
            right:-20px;/*跟宽度保持一致*/
            top:0;
            z-index: 2;
        }
        /*大3个px的边 26-20/2*/
        .interval{
            width: 0;
            height: 0;
            border-top: 26px solid transparent;/*高度一半*/
            border-left: 26px solid #fff; /*调整宽度*/
            border-bottom: 26px solid transparent;/*高度一半*/
            position: absolute;
            right:-26px;/*跟宽度保持一致*/
            top:-6px;
            z-index: 1;
        }
    }
</style>

父页面 引用:

    <template>
              ①  <triangle_step :active.sync="active" :stepArr="stepArr" :width="width"></triangle_step>
            <!--选择订单-->
		<selectOrder :active.sync="active" v-if="stepArr[active].title==='选择订单'"></selectOrder>
		<!--确认订单-->
		<enterOrder :active.sync="active" v-if="stepArr[active].title==='确认订单'"></enterOrder>
		<!--发票信息-->
		<invoiceInfo :active.sync="active" v-if="stepArr[active].title==='确认发票信息'"></invoiceInfo>
		<!--发票信息-->
		<applySuccess :active.sync="active" v-if="stepArr[active].title==='合同申请成功'"></applySuccess>
    </template>
    <script>
              ②  import triangle_step from "@/components/triangle_step/index.vue"
	         import selectOrder from "./step/selectOrder.vue"
	         import enterOrder from "./step/enterOrder.vue"
	         import invoiceInfo from "./step/invoiceInfo.vue"
	         import applySuccess from "./step/applySuccess.vue"
	      ③  components: {
     		    triangle_step,
     		    selectOrder,
		    enterOrder,
		    invoiceInfo,
		    applySuccess
		             }
    </script>
  • 5
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Cnyzu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值