vue時(shí)間線組件的使用方法
本文實(shí)例為大家分享了vue時(shí)間線組件的具體實(shí)現(xiàn)代碼,供大家參考,具體內(nèi)容如下
效果
vue-時(shí)間線組件(時(shí)間軸組件)代碼
<template> <ul class='timeline-wrapper'><li v-for='t in timelineList' :key='t.id'><div class='timeline-box'> <div class='out-circle'><div class='in-circle'></div> </div> <div class='long-line'></div></div><div class='timeline-content'> <div class='timeline-date'>{{t.date}}</div> <div class='timeline-title'>{{ t.title}}</div> <div class='timeline-desc'>{{ t.content}}</div></div> </li> </ul></template><script type='text/babel'> import Vue from ’vue’ export default Vue.component(’Timeline’,{name: 'Timeline',props: { timelineList: {type: Array,default: () => { return []} }} })</script><style scoped lang='scss'> ul.timeline-wrapper {list-style: none;margin: 0;padding: 0; } /* 時(shí)間線 */ .timeline-item {position: relative;.timeline-box { text-align: center; position: absolute; .out-circle {width: 16px;height: 16px;background: rgba(14, 116, 218, 0.1);box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.1);/*opacity: 0.1;*/border-radius: 50%;display: flex;align-items: center;.in-circle { width: 8px; height: 8px; margin: 0 auto; background: rgba(14, 116, 218, 1); border-radius: 50%; box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.1);} } .long-line {width: 2px;height: 98px;background: rgba(14, 116, 218, 1);box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.1);opacity: 0.1;margin-left: 8px; }}.timeline-content { box-sizing: border-box; margin-left: 20px; height: 106px; padding: 0 0 0 20px; text-align: left; margin-bottom: 30px; .timeline-title {font-size: 14px;word-break: break-all;margin-bottom: 16px;color: #333;font-weight: 500;/*display: inline;*/ } .timeline-date {font-size: 16px;color: #333;font-weight: 500;margin-bottom: 16px; } .timeline-desc {font-size: 14px;color: #999999; }} } .timeline-item:last-of-type .timeline-content {margin-bottom: 0; }</style>
應(yīng)用
// 父組件引用<timeline :timeline-list='dongtai'></timeline>
// 引入組件,記得組件路徑要根據(jù)自己的來(lái)import Timeline from './Timeline';// 在data()返回的對(duì)象里聲明數(shù)組dongtai:[]
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. CSS清除浮動(dòng)方法匯總2. XML 非法字符(轉(zhuǎn)義字符)3. HTML5實(shí)戰(zhàn)與剖析之觸摸事件(touchstart、touchmove和touchend)4. React優(yōu)雅的封裝SvgIcon組件示例5. CSS百分比padding制作圖片自適應(yīng)布局6. HTTP協(xié)議常用的請(qǐng)求頭和響應(yīng)頭響應(yīng)詳解說(shuō)明(學(xué)習(xí))7. TypeScript實(shí)現(xiàn)十大排序算法之歸并排序示例詳解8. 不要在HTML中濫用div9. 深入了解React中的合成事件10. XML入門的常見問(wèn)題(三)
