Vue实现时间轴效果

 更新时间:2022年03月03日 11:05:37   作者:theMuseCatcher  
这篇文章主要为大家详细介绍了Vue实现时间轴效果,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了Vue实现时间轴效果的具体代码,供大家参考,具体内容如下

时间轴上的时间点数和描述文本均可自定义设置

效果图如下:

①创建时间轴组件Timeline.vue:

<template>
  <div class="m-timeline-area">
    <div class="m-timeline">
      <div
        :class="['m-timeline-item', {'last': n === totalDots}]"
        v-for="n in totalDots"
        :key="n">
        <div class="u-tail"></div>
        <div class="u-dot"></div>
        <div class="u-content">
          <p>{{ timelineDesc[n-1] }}</p>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'Timeline',
  props: {
    timelineDesc: {
      type: Array,
      default: () => {
        return []
      }
    },
    totalDots: {
      type: Number,
      default: 3
    }
  }
}
</script>
<style lang="less" scoped>
@blue: #1890ff;
@green: #52c41a;
@red: #f5222d;
@gray: rgba(0,0,0,.25);
.m-timeline-area {
  width: 360px;
  margin: 30px auto;
  .m-timeline {
    .m-timeline-item {
      position: relative;
      padding-bottom: 30px;
      .u-tail {
        position: absolute;
        top: 10px;
        left: 5px;
        height: calc(100% - 10px);
        border-left: 2px solid #e8e8e8; // 实线
        // border-left: 2px dotted #e8e8e8; // 点线
        // border-left: 2px dashed #e8e8e8; // 虚线
      }
      .u-dot {
        position: absolute;
        width: 8px;
        height: 8px;
        border: 2px solid @blue;
        border-radius: 50%;
      }
      .u-content {
        position: relative;
        top: -6px;
        margin-left: 25px;
        word-break: break-word;
        line-height: 24px;
      }
    }
    .last {
      .u-tail {
        display: none;
      }
    }
  }
}
</style>

②在要使用的页面引入:

<Timeline :totalDots="5" :timelineDesc="timelineDesc" />
import Timeline from '@/components/Timeline'
components: {
    Timeline
}
timelineDesc: ['Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.', 'Create a services site', 'Create a services site', 'Create a services site', 'Create a services site']

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

相关文章

  • vue下的elementui轮播图自适应高度问题

    vue下的elementui轮播图自适应高度问题

    这篇文章主要介绍了vue下的elementui轮播图自适应高度问题,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2022-09-09
  • vue2实现无感刷新token的方式详解

    vue2实现无感刷新token的方式详解

    在Web应用中,用户需要通过认证和授权才能访问受保护的资源,为了实现认证和授权功能,通常需要使用Token来标识用户身份并验证其权限,本文给大家介绍了vue2实现无感刷新token的方式,需要的朋友可以参考下
    2024-02-02
  • 开发Vue树形组件的示例代码

    开发Vue树形组件的示例代码

    本篇文章主要介绍了开发Vue树形组件的示例代码,它展现了组件的递归使用。小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-12-12
  • Vue实现输入框回车发送和粘贴文本与图片功能

    Vue实现输入框回车发送和粘贴文本与图片功能

    这篇文章主要为大家详细介绍了Vue如何实现聊天输入框回车发送、粘贴文本(包括HTML)、粘贴图片等功能,文中的实现方法讲解详细,需要的可以参考一下
    2022-05-05
  • vue实现手机验证码登录

    vue实现手机验证码登录

    这篇文章主要为大家详细介绍了vue实现手机验证码登录,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2021-11-11
  • vue中el-date-picker选择日期的限制的项目实践

    vue中el-date-picker选择日期的限制的项目实践

    ElementUI的el-date-picker使用时,有时候想要限制用户选择的时间范围,本文就来介绍了vue中el-date-picker选择日期的限制的项目实践,感兴趣的可以了解一下
    2023-10-10
  • vue中关于computed的this指向问题

    vue中关于computed的this指向问题

    这篇文章主要介绍了vue中关于computed的this指向问题,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2023-07-07
  • vant 解决tab切换插件标题样式自定义的问题

    vant 解决tab切换插件标题样式自定义的问题

    这篇文章主要介绍了vant 解决tab切换插件标题样式自定义的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2020-11-11
  • 如何使用sm4js进行加密和国密sm4总结

    如何使用sm4js进行加密和国密sm4总结

    近期由于公司项目的需要开始研究国密SM4加密,下面这篇文章主要给大家介绍了关于如何使用sm4js进行加密和国密sm4的相关资料,文中通过实例代码介绍的非常详细,需要的朋友可以参考下
    2023-04-04
  • vue2.0中goods选购栏滚动算法的实现代码

    vue2.0中goods选购栏滚动算法的实现代码

    这篇文章主要介绍了vue2.0中goods选购栏滚动算法的实现代码,需要的朋友可以参考下
    2017-05-05

最新评论