自定义时间轴组件样式

实现一个时间轴的样式,并且点击可以展开详情
效果图如下:
在这里插入图片描述

1.html

<div class='timeline-step'>
    <div
        class='time-list'
        v-for='(item, index) in timeList'
        :key='index'
    >
        <div class='left'>
            <img
                :src='require(`@assets/safety-analysis${item.attackType}.png`)'
                alt=''
            >
            <div class='connecting-line'></div>
        </div>
        <div class='right'>
            <div class='title-common'>
                <p>
                    <span>{{ item.time }}</span>
                    <span>{{ item.title }}</span>
                    <Icon
                        :custom="item.isShow?'bl-icon-arrow-down':'bl-icon-arrow-left'"
                        class='arrow'
                        @click='showDetail(item)'
                    />
                </p>
                <p :title='item.description'>{{ item.description }}</p>
            </div>
            <div v-if='item.isShow'>
                <Divider/>
                <div class='detail-info'>
                    <div>
                        <p>攻击类型</p>
                        <p>{{ item.type }}</p>
                    </div>
                    <div>
                        <p>源IP地址</p>
                        <p>{{ item.originIP }}</p>
                    </div>
                    <div>
                        <p>目的IP地址</p>
                        <p>{{ item.purposeIP }}</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

2.css

.timeline-step {
    position: absolute;
    overflow-y: auto;
    width: calc(100% - 16px);
    height: 554px;
    padding-right: 10px;

    .time-list {
        display: flex;

        .left {
            width: 38px;
            position: relative;

            img {
                width: 38px;
                height: 38px;
            }

            .connecting-line {
                width: 2px;
                height: calc(100% - 38px);
                position: absolute;
                top: 38px;
                left: 18px;
                background: #d8d8d8;
            }
        }

        .right {
            width: calc(100% - 42px);
            margin-left: 4px;
            margin-bottom: 16px;
            padding: 8px 12px 12px;
            background-color: #f5f5f5;

            .title-common {
                p:nth-of-type(1) {
                    height: 22px;
                    font-weight: bold;
                    position: relative;
                    color: rgba(0, 0, 0, 0.85);

                    span:nth-of-type(2) {
                        margin-left: 12px;
                    }

                    .arrow {
                        position: absolute;
                        right: 0;
                        top: 2px;
                        cursor: pointer;
                        color: rgba(0, 0, 0, 0.45);
                    }
                }

                p:nth-of-type(2) {
                    font-size: 12px;
                    margin-top: 4px;
                    color: rgba(0, 0, 0, 0.45);
                }
            }

            .ivu-divider-horizontal {
                margin: 8px 0;
            }

            .detail-info {
                display: flex;
                justify-content: space-between;

                > div {
                    flex: 1;
                    font-weight: bold;
                    font-size: 12px;

                    p:nth-of-type(1) {
                        font-weight: normal;
                        color: rgba(0, 0, 0, 0.45);
                    }
                }
            }

        }

        &:last-child {
            .connecting-line {
                width: 0;
            }

        }
    }
}

3.js

data () {
    return {
        timeList: [
            {
                title: '标题1',
                attackType: 'scout',
                time: '2021-12-06 11:28:35',
                type: '端口扫描',
                originIP: '220.0.0.0',
                purposeIP: '220.0.0.1',
                description: '描述描述描述描述描述描述描述描述描述描述描述1',
                isShow: false,
            },
            {
                title: '标题2',
                attackType: 'delivery',
                time: '2021-12-06 11:28:35',
                type: '端口扫描',
                originIP: '220.0.0.0',
                purposeIP: '220.0.0.1',
                description: '描述描述描述描述描述描述描述描述描述描述描述2',
                isShow: false,
            },
            {
                title: '标题3',
                attackType: 'scout',
                time: '2021-12-06 11:28:35',
                type: '端口扫描',
                originIP: '220.0.0.0',
                purposeIP: '220.0.0.1',
                description: '描述描述描述描述描述描述描述描述描述描述描述3',
                isShow: false,
            },
            {
                title: '标题4',
                attackType: 'delivery',
                time: '2021-12-06 11:28:35',
                type: '端口扫描',
                originIP: '220.0.0.0',
                purposeIP: '220.0.0.1',
                description: '描述描述描述描述描述描述描述描述描述描述描述4',
                isShow: false,
            },
        ],
    }
},
methods: {
    // 点击:展开/关闭详情
    showDetail (row) {
        row.isShow = !row.isShow
    },
},

自定义step样式

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值