Vue實現(xiàn)時間軸效果
本文實例為大家分享了Vue實現(xiàn)時間軸效果的具體代碼,供大家參考,具體內(nèi)容如下
時間軸上的時間點數(shù)和描述文本均可自定義設(shè)置
效果圖如下:
①創(chuàng)建時間軸組件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']
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
vue下的elementui輪播圖自適應(yīng)高度問題
這篇文章主要介紹了vue下的elementui輪播圖自適應(yīng)高度問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-09-09Vue實現(xiàn)輸入框回車發(fā)送和粘貼文本與圖片功能
這篇文章主要為大家詳細(xì)介紹了Vue如何實現(xiàn)聊天輸入框回車發(fā)送、粘貼文本(包括HTML)、粘貼圖片等功能,文中的實現(xiàn)方法講解詳細(xì),需要的可以參考一下2022-05-05vue中el-date-picker選擇日期的限制的項目實踐
ElementUI的el-date-picker使用時,有時候想要限制用戶選擇的時間范圍,本文就來介紹了vue中el-date-picker選擇日期的限制的項目實踐,感興趣的可以了解一下2023-10-10vant 解決tab切換插件標(biāo)題樣式自定義的問題
這篇文章主要介紹了vant 解決tab切換插件標(biāo)題樣式自定義的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-11-11如何使用sm4js進(jìn)行加密和國密sm4總結(jié)
近期由于公司項目的需要開始研究國密SM4加密,下面這篇文章主要給大家介紹了關(guān)于如何使用sm4js進(jìn)行加密和國密sm4的相關(guān)資料,文中通過實例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-04-04vue2.0中g(shù)oods選購欄滾動算法的實現(xiàn)代碼
這篇文章主要介紹了vue2.0中g(shù)oods選購欄滾動算法的實現(xiàn)代碼,需要的朋友可以參考下2017-05-05