Vue时间轴

之前有这样子的需求没有用第三方插件于是自己写一个简单的时间轴

时间轴滚动条并左右切换滚动条位置相对应移动

在这里插入图片描述

<div class="time-scrollbar">
        <div v-if="timeLineData.length>0" class="scrollbar-content">
          <div class="arrow" @click="clickLeft"> <el-icon :size="40"><ArrowLeft /></el-icon></div>
          <el-scrollbar ref="timeScrollbarRef" @scroll="scrollChange"  always >
            <TimeLine ref="timeLineRef" id="timeLineId" class="time-line" direction="vertical" :stripe="true" sizeIcon="large" 
            :timelineList="timeLineData" :hollowIcon="true" :hasNameCenter="false"/>
          </el-scrollbar>
          <div class="arrow" @click="clickRight"><el-icon :size="40"><ArrowRight /></el-icon></div>
        </div>
        <div v-else class="text-info">暂无数据</div>
   </div>

const clickLeft = () => {
  if(start.value > 0) {
    start.value = start.value-1398
    end.value = end.value-10
    timeScrollbarRef.value.scrollTo(start.value, end.value)
    // 点击更改数据
     // page.value = page.value >=1? 1: page.value-1 
     // getTimeLineData()
  }
}
const scrollChange = (scrollData: any) => {
  start.value = scrollData.scrollLeft
}
const clickRight = () => {
  const contentWidth = document.getElementById('timeLineId')?.offsetWidth as number
  if((end.value + 1398) < contentWidth) {
    start.value = start.value+1398
    end.value = end.value+10
    timeScrollbarRef.value.scrollTo(start.value, end.value)
  }
  //  点击更改数据
  // page.value = page.value+1 
  // getTimeLineData()
}

//TimeLine页面

<template>
  <div class="time-line-box">
    <el-timeline
      :class="{
        timeline: true,
        'timeline-stripe': stripe,
        'timeline-vertical': direction === 'vertical',
        'name-center': hasNameCenter
      }"
      >
      <el-timeline-item
        v-for="(item, index) in timelineList"
        :key="index"
        :timestamp="!$slots.item ? item.time : undefined"
        placement="top"
        center
        :color="item.color"
        :hollow="hollowIcon"
        :size="sizeIcon"
        :icon="hasNameCenter ? () => item.name : undefined"
        :style="
          direction === 'vertical'
            ? `width: calc(${100 / timelineList.length}% - 2px)`
            : 'width: 100%'
        "
        @click="item.onClick"
      >
        <template v-if="$slots.item">
          <slot name="item" :data="item" />
        </template>
        <template v-else>
          <div v-if="!hasNameCenter" class="name">
            {{ item.name }}
          </div>
          <div class="time">
            {{ item.keepTime }}
          </div>
        </template>
      </el-timeline-item>
    </el-timeline>
  </div>
    
</template>
<script lang="ts" setup>
import { PropType } from 'vue'
import { Card } from '@/components'

defineProps({
  stripe: {
    type: Boolean,
    default: false
  },
  direction: {
    type: String as PropType<'horizontal' | 'vertical'>,
    default: 'horizontal'
  },
  timelineList: {
    type: Array as PropType<any[]>,
    default: () => []
  },
  height: {
    type: [Number, String],
    default: () => 150
  },
  hasNameCenter: {
    type: Boolean,
    default: false
  },
  hollowIcon:{
    type: Boolean,
    default: false
  },
  sizeIcon:{
    type: String as PropType<'normal' | 'large'>,
    default: 'normal'
  }
})
</script>
<style lang="scss" scoped>
.time-line-box {
  :deep(.timeline) {
    margin: 0;
    padding: 18px 0 0;
    .el-timeline-item__tail {
      border-left: 2px solid rgba(255, 255, 255, 0.3);
    }
    .el-timeline-item__timestamp {
      margin-bottom: 0;
      padding-top: 0;
    }
    .el-timeline-item__timestamp,
    .el-timeline-item__content {
      font-size: 14px;
      font-weight: normal;
      color: #fff;
    }
    // .el-timeline-item {
    //   width: 100% !important;
    //   // padding: 0 0 10px;
    // }
  }

  :deep(.timeline-vertical) {
    display: flex;
    .el-timeline-item__tail {
      border-left: none;
      border-top: 2px solid rgba(255, 255, 255, 0.3);
      width: 100%;
      position: absolute;
      top: 6px;
    }
    .el-timeline-item__timestamp {
      margin-bottom: 8px;
      padding-top: 4px;
    }
    .el-timeline-item__node {
      left: 35%;
      margin-top: 15px;
      border-color: #037DFF;
    }
    .el-timeline-item__wrapper {
      padding-left: 0;
      position: absolute;
      top: 20px;
      text-align: center;
    }
  }
  :deep(.timeline-stripe) {
    padding-top: 85px;

    .el-timeline-item {
      .el-timeline-item__wrapper {
        transform: translateY(-165%);
      }
      &:nth-child(2n) {
        .el-timeline-item__wrapper {
          transform: translateY(0%);
        }
      }
    }
  }
  :deep(.name-center) {
    .el-timeline-item__node {
      height: 20px;
      border-radius: 4px;
      width: auto;
      padding: 0 5px;
      font-size: 14px;
      font-weight: 500;
      color: #fff;
      .el-timeline-item__icon {
        width: inherit;
        height: inherit;
        line-height: 20px;
      }
    }
  }
}
</style>

记录一下。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/439765.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

基于FastAPI构造一个AI模型部署应用

前言 fastapi是目前一个比较流行的python web框架&#xff0c;在大模型日益流行的今天&#xff0c;其云端部署和应用大多数都是基于fastapi框架。所以掌握和理解fastapi框架基本代码和用法尤显重要。 需要注意的是&#xff0c;fastapi主要是通过app对象提供了web服务端的实现代…

Java+SpringBoot+Vue+MySQL实战:打造智能餐厅点餐系统

✍✍计算机编程指导师 ⭐⭐个人介绍&#xff1a;自己非常喜欢研究技术问题&#xff01;专业做Java、Python、微信小程序、安卓、大数据、爬虫、Golang、大屏等实战项目。 ⛽⛽实战项目&#xff1a;有源码或者技术上的问题欢迎在评论区一起讨论交流&#xff01; ⚡⚡ Java实战 |…

图机器学习(3)-连接层面的特征工程

0 问题定义 通过已经连接去猜未知连接&#xff1a; 有两个思路&#xff1a;

基于FPGA加速的bird-oid object算法实现

导语 今天继续康奈尔大学FPGA 课程ECE 5760的典型案例分享——基于FPGA加速的bird-oid object算法实现。 &#xff08;更多其他案例请参考网站&#xff1a; Final Projects ECE 5760&#xff09; 1. 项目概述 项目网址 ECE 5760 Final Project 模型说明 Bird-oid object …

基于springboot实现大学生兼职网站系统项目【项目源码+论文说明】计算机毕业设计

基于springboot实现大学生兼职系统演示 摘要 现代化的市场中&#xff0c;人们日常的工作、生活都在不断的提速&#xff0c;而人们在工作与生活中与互联网的结合也越来越紧密&#xff0c;通过与互联网紧密的结合可以更好地实现日常工作的线上化、信息化、便捷化。现如今的各行各…

案例研究|辛格林电梯借助DataEase实现数据整合与智能展示

辛格林电梯&#xff08;SIGLEN&#xff09;于2012年创立&#xff0c;是电梯领域的领军品牌之一。该公司总部位于广东佛山&#xff0c;是全国首批获得A1级电梯制造资质的企业&#xff0c;拥有省级工程技术研究中心。辛格林电梯专注于研发和生产高品质电梯产品&#xff0c;涵盖别…

Spring Security认证授权流程详解

认证的工作原理 过滤链 Spring Security框架的作用就是安全访问控制即对所有进入系统的请求进行拦截, 校验每个请求是否能够访问到它所期望的资源 通过Filter或AOP等技术可以实现安全访问控制功能,而Spring Security对Web资源的保护是靠Filter实现的,Spring Security有一个过…

Linux运维工程师不可或缺的10款工具

运维工程师在日常工作中频繁运用的10款工具&#xff0c;并细致阐述每款工具的功能、适用场景以及其卓越之处。 1. Shell脚本&#xff1a; 功能&#xff1a;主要用于自动化任务和批处理作业。 适用场景&#xff1a;频繁用于文件处理、系统管理、简单的网络管理等操作。 优势&…

【学习教程】Vision Pro:开发学习资源

unity 官方网站上线了一款课程,准备好迎接 Apple Vision Pro:免费学习资源汇总。 本合集则是为想要探索 Apple Vision Pro 的创作者提供全方位指导, 由浅入深,与你一同创造前所未有的 沉浸式空间交互体验 的新奇内容。 合集包含最新的开发技术文档。从入门的基础知识核心…

基于vue的联通积分商城数据可视化APP设计与实现

目 录 摘 要 I Abstract II 引 言 1 1 前端技术介绍 3 1.1 前端开发语言 3 1.1.1 HTML5 3 1.1.2 CSS3 3 1.1.3 JavaScript 3 1.2 MVVM开发模式 4 1.3 Vue框架 4 1.4 Axios技术 5 1.5 ECharts 5 1.6 数据库技术 5 1.7 本章小结 6 2 前端开发的分析 7 2.1 功能性需求分析 7 2.2 …

Navicat连接数据库出现的问题

Navicat使用教程——连接/新建数据库、SQL实现表的创建/数据插入、解决报错【2059-authentication plugin‘caching_sha2_password’……】_2059authentication plugin-CSDN博客

灭火新选择:恒峰便携式森林灭火泵,轻松应对火情

森林中火灾是一种常见且危害巨大的自然灾害。一旦发生&#xff0c;如果没有及时、有效的扑救手段&#xff0c;后果将不堪设想。然而&#xff0c;传统的消防设备往往体积庞大、重量不轻&#xff0c;操作复杂&#xff0c;难以在森林中迅速有效地发挥作用。而现在&#xff0c;我们…

专题一 - 双指针 - leetcode 1089. 复写零 - 简单难度

leetcode 1089. 复写零 leetcode 1089. 复写零 | 简单难度1. 题目详情1. 原题链接2. 基础框架 2. 解题思路1. 题目分析2. 算法原理3. 时间复杂度 3. 代码实现4. 知识与收获 leetcode 1089. 复写零 | 简单难度 1. 题目详情 给你一个长度固定的整数数组 arr &#xff0c;请你将…

大白话说---“消息队列”

目录 一、什么是消息队列&#xff1f; 二、消息队列的作用 1.解耦 2.削峰 3.异步 三、消息队列的使用场景 1.传统设计 2.加入消息队列后的优化 四、常见的消息队列 一、什么是消息队列&#xff1f; 从名称上&#xff0c;我们就可以得到两个关键信息&#xff0c;即“消息”和…

ODI报错

三月 08, 2024 1:20:09 下午 oracle.odi.mapping 信息: Start generation of map physical design: MapPhysicalDesign New_Mapping.物理 三月 08, 2024 1:20:09 下午 oracle.odi.mapping 信息: Finished generation of map physical design: MapPhysicalDesign New_Mapping.物…

Word背景图片设置,提升文章美观度的4个小技巧!

“我才刚开始使用Word&#xff0c;想问问大家Word中背景图片应该怎么设置呢&#xff1f;有什么比较好用的设置方法可以分享一下吗&#xff1f;” 在日常办公中&#xff0c;我们经常需要使用Word来对文件进行处理。在编写Word时&#xff0c;如果给文档加入背景图片&#xff0c;会…

用云手机进行舆情监测有什么作用?

在信息爆炸的时代&#xff0c;舆情监测成为企业和政府决策的重要工具。通过结合云手机技术&#xff0c;舆情监测系统在品牌形象维护、市场竞争、产品研发、政府管理以及市场营销等方面发挥着关键作用&#xff0c;为用户提供更智能、高效的舆情解决方案。 1. 品牌形象维护与危机…

猫冻干价格差距大,定价合理吗?价位合适的主食冻干推荐

随着养猫知识的普及&#xff0c;主食冻干喂养受到越来越多铲屎官的欢迎。然而&#xff0c;价格仍是部分铲屎官的考虑因素。事实上&#xff0c;像我这样的资深铲屎官&#xff0c;早已开始主食冻干喂养。虽然主食冻干价格稍高&#xff0c;但其为猫咪带来的好处是无法替代的。 对于…

【动态规划.2】5292. 跳台阶

承接上一篇 升级版&#xff0c;别怕&#xff0c;上一篇弄会了&#xff0c;这个就是 豆芽菜✌️ https://www.acwing.com/problem/content/description/5295/ f1.递归 #include <bits/stdc.h> // 2024-03-08 Come on ! using namespace std; #define ll long l…

git克隆过程报错

设置 git config 来强制 git 使用 HTTP 1.1 git config --global http.version HTTP/1.1想将其设置回 HTTP2&#xff0c;你可以这样做 git config --global http.version HTTP/2