最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue實現(xiàn)橫向時間軸組件方式

 更新時間:2022年12月05日 08:40:56   作者:HELLO_小仙女~  
這篇文章主要介紹了vue實現(xiàn)橫向時間軸組件方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

前言

項目中有需要用到橫向時間軸,網(wǎng)上大部分組件不滿足 功能需要,于是自己寫了一個。先上簡單的demo。

功能

  • 默認獲取初始數(shù)據(jù)顯示對應(yīng)的時間軸和時間點。
  • 當(dāng)超出屏幕后,滑動滾動條加載更多頁,類似分頁加載。
  • 某個大的時間軸節(jié)點鼠標(biāo)放入需要顯示相關(guān)信息。
  • 某兩個大節(jié)點之間會有子節(jié)點出現(xiàn)。
  • 每個子節(jié)點會有對應(yīng)的子節(jié)點詳情內(nèi)容展示,無詳情內(nèi)容介紹的只展示子節(jié)點。

效果圖

vue時間軸視頻效果

在這里插入圖片描述

代碼

Timeline組件封裝

<template>
  <ul class="timeline-wrapper" @scroll="scrollEvent">
    <li class="timeline-item" v-for="item in timelineList" :key="item.id">
      <div class="timeline-box">
        <div class="out-circle">
          <div class="in-circle"></div>
          <div class="timeline-date">
            <el-popover
              placement="bottom"
              title="標(biāo)題"
              width="200"
              trigger="hover"
              :content="item.content"
            >
              <el-button type="text" slot="reference" class="father-text">{{
                item.date
              }}</el-button>
            </el-popover>
          </div>
        </div>
        <div
          class="long-line"
          v-show="item.isShow"
          :style="`width:${
            item.children ? (item.children.length + 1) * 100 : 1 * 100
          }px`"
        >
          <div
            v-for="(subItem, index) in item.children"
            :key="subItem.id"
            class="sub-item-box"
          >
            <span>{{ subItem.name + ":" + subItem.num }}人</span>
            <!-- 根據(jù)奇數(shù)偶數(shù)來判斷向上還是向下 -->
            <div
              :class="`sub-line-box ${
                index % 2 == 0 ? 'top-line-box' : 'bottom-line-box'
              }`"
              v-show="subItem.content"
            >
              <div
                :class="`children-line-box ${
                  index % 2 == 0 ? 'top-line' : 'bottom-line'
                }`"
              ></div>
              <div
                :class="`children-box ${
                  index % 2 == 0 ? 'top-children-box' : 'bottom-children-box'
                }`"
              >
                {{ subItem.content }}
              </div>
            </div>
          </div>
        </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 [];
      },
    },
  },
  mounted() {},
  methods: {
    scrollEvent(e) {
      this.$emit("scrollEvent", e);
    },
    handleBottomClick() {
      this.$emit("handleBottomClick");
    },
  },
});
</script>
<style scoped lang="scss">
ul.timeline-wrapper {
  list-style: none;
  margin: 0;
  padding: 0;
  padding: 200px 20px;
  white-space: nowrap;
  overflow-x: scroll;
}

/* 時間線 */
.timeline-item {
  position: relative;
  display: inline-block;
  .timeline-box {
    text-align: center;

    // position: absolute;
    display: flex;
    align-items: center;
    .out-circle {
      width: 16px;
      height: 16px;
      background: rgba(14, 116, 218, 0.3);
      box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.4);
      /*opacity: 0.1;*/
      border-radius: 50%;
      display: flex;
      align-items: center;
      cursor: pointer;
      .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);
      }
      .timeline-date {
        color: #333;
        margin-top: 40px;
        .father-text {
          font-weight: 900;
          font-size: 16px;
          margin-left: -15px;
        }
      }
    }

    .long-line {
      // width: 300px;
      height: 2px;
      background: rgba(14, 116, 218, 0.2);
      box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.3);
      display: flex;
      flex-direction: revert;
      justify-content: space-around;
      .sub-item-box {
        margin-top: -20px;
        position: relative;
        .sub-line-box {
          // cursor: pointer;
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;
          .children-line-box {
            width: 0px;
            border-left: 1px solid rgba(14, 116, 218, 0.3);
          }
          .children-box {
            flex-wrap: wrap;
            display: flex;
            justify-content: center;
            align-items: center;
            border: 1px solid rgba(14, 116, 218, 0.3);
            white-space: break-spaces;
            text-align: center;
            padding: 5px;
          }
        }
        .top-line-box {
          margin-top: -100px;
          height: 60px;
        }
        .bottom-line-box {
          margin-top: 5px;
          height: 150px;
        }
        .top-line {
          height: 65px;
        }
        .bottom-line {
          height: 120px;
        }
        .top-children-box {
          margin-top: -90px;
          // height: 30px;
          width: 100px;
        }
        .bottom-children-box {
          // height: 120px;
          width: 150px;
        }
      }
    }
  }

  .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-desc {
      font-size: 14px;
      color: #999999;
    }
  }
}

.timeline-item:last-of-type .timeline-content {
  margin-bottom: 0;
}
</style>

父組件引用:

<template>
  <Timeline :timelineList="timeLineArr" @scrollEvent="scrollEvent" />
</template>

<script>
import Timeline from "@/components/Timeline";
export default {
  components: {
    Timeline,
  },
  computed: {},
  data() {
    return {
      nomore: false,
      // 初始話模擬數(shù)據(jù),數(shù)據(jù)較多時即可,形成滾動條。
      timeLineArr: [
        {
          id: 1,
          date: "2015",
          title: "2015",
          content: "2015年初,團隊在北京注冊公司",
          isShow: true,
          children: [],
        },
        {
          id: 2,
          date: "2016",
          title: "2016",
          content: "2016年,公司成立銷售團隊",
          isShow: true,
          children: [
            {
              name: "創(chuàng)始團隊",
              num: 5,
              content: "前期公司規(guī)劃",
            },
          ],
        },
        {
          id: 3,
          date: "2017",
          title: "2017",
          content: "2017年,公司決定創(chuàng)建自有品牌,進行規(guī)模擴招團隊",
          isShow: true,
          children: [
            {
              name: "銷售部",
              num: 10,
              content: "負責(zé)市場開發(fā)",
            },
            {
              name: "技術(shù)部",
              num: 20,
              content: "前端:5人,后端10人,測試5人",
            },
          ],
        },
        {
          id: 4,
          date: "2018",
          title: "2018",
          content: "2018年,新增兩個部門",
          isShow: true,
          children: [
            {
              name: "人力資源部",
              num: 3,
              content: "負責(zé)人才招聘",
            },
            {
              name: "財務(wù)部",
              num: 2,
              content: "財務(wù)結(jié)算",
            },
            {
              name: "總裁辦",
              num: 2,
              content: "",
            },
          ],
        },
        {
          id: 5,
          date: "2019",
          title: "2019",
          content: "2019年",
          isShow: true,
          children: [
            {
              name: "商務(wù)企劃部",
              num: 2,
              content: "對外合作",
            },
          ],
        },
      ],
    };
  },
  methods: {
  // 滾動監(jiān)聽
    scrollEvent(e) {
      if (
        e.srcElement.scrollLeft + e.srcElement.clientWidth >=
        e.srcElement.scrollWidth
      ) {
        console.log("嘿嘿我在底部觸發(fā)了");
        // 這里正常請求數(shù)據(jù)即可
        let data = [
          {
            id: 12,
            date: "2020",
            title: "2020",
            content: "2020年,受全球疫情影響,公司暫未擴招人員",
            isShow: true,
            children: [],
          },
          {
            id: 22,
            date: "2021",
            title: "2021",
            content: "公司被xxx投資公司注入資本1000萬,公司天使輪融資成功",
            isShow: true,
            children: [
              {
                name: "倉儲部",
                num: 30,
                content: "負責(zé)貨物存儲",
              },
              {
                name: "物流部",
                num: 40,
                content: "負責(zé)自有配送",
              },
            ],
          },
          {
            id: 23,
            date: "2022",
            title: "2022",
            content: "公司進入A輪融資,公司被xx投資公司注入資本8000萬。",
            isShow: false,
            children: [],
          },
        ];
        if (!this.nomore) {
          this.timeLineArr[this.timeLineArr.length - 1].isShow = true;
          this.timeLineArr.push(...data);
          this.nomore = true;
        }
      }
    },
  },
};
</script>

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue前端代碼如何通過maven打成jar包運行

    vue前端代碼如何通過maven打成jar包運行

    這篇文章主要介紹了vue前端代碼如何通過maven打成jar包運行問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-01-01
  • Vue之前端體系與前后端分離詳解

    Vue之前端體系與前后端分離詳解

    本篇文章主要介紹了Vue之前端體系與前后端分離,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2021-10-10
  • 深入探討Vue3實現(xiàn)多數(shù)據(jù)變化監(jiān)聽的方式

    深入探討Vue3實現(xiàn)多數(shù)據(jù)變化監(jiān)聽的方式

    隨著 Vue 3 的發(fā)布,框架帶來了更多的新特性和增強,其中之一就是 watch 函數(shù)的升級,這一改進使得多個數(shù)據(jù)的變化偵聽更加優(yōu)雅和靈活,本文將深入探討 Vue 3 中的 watch 函數(shù),以及如何以更加優(yōu)雅的方式實現(xiàn)對多個數(shù)據(jù)變化的監(jiān)聽
    2023-08-08
  • vue攔截器及請求封裝代碼

    vue攔截器及請求封裝代碼

    這篇文章主要介紹了vue攔截器及請求封裝代碼,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-08-08
  • Vue父組件調(diào)用子組件函數(shù)實現(xiàn)

    Vue父組件調(diào)用子組件函數(shù)實現(xiàn)

    這篇文章主要介紹了Vue父組件調(diào)用子組件函數(shù)實現(xiàn),全文通過舉例子及代碼的形式進行了一個簡單的介紹,希望大家能夠理解并且學(xué)習(xí)到其中知識
    2021-08-08
  • 基于vue實現(xiàn)簡易打地鼠游戲

    基于vue實現(xiàn)簡易打地鼠游戲

    這篇文章主要為大家詳細介紹了基于vue實現(xiàn)簡易打地鼠游戲,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2020-08-08
  • Vue實現(xiàn)hash模式網(wǎng)址方式(就是那種帶#的網(wǎng)址、井號url)

    Vue實現(xiàn)hash模式網(wǎng)址方式(就是那種帶#的網(wǎng)址、井號url)

    這篇文章主要介紹了Vue實現(xiàn)hash模式網(wǎng)址方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-07-07
  • Vue使用mind-map實現(xiàn)在線思維導(dǎo)圖

    Vue使用mind-map實現(xiàn)在線思維導(dǎo)圖

    Vue中的Mind-Map通常是指使用Vue.js這個前端框架構(gòu)建的思維導(dǎo)圖組件或庫,它可以幫助開發(fā)者在Web應(yīng)用中創(chuàng)建動態(tài)、交互式的思維導(dǎo)圖,讓用戶可以直觀地組織信息和結(jié)構(gòu)化數(shù)據(jù),本文介紹了Vue使用mind-map實現(xiàn)在線思維導(dǎo)圖,需要的朋友可以參考下
    2024-07-07
  • vue數(shù)字金額動態(tài)變化功能實現(xiàn)方法詳解

    vue數(shù)字金額動態(tài)變化功能實現(xiàn)方法詳解

    這篇文章主要介紹了vue實現(xiàn)數(shù)字金額動態(tài)變化效果,數(shù)字動態(tài)變化是我們在前端開發(fā)中經(jīng)常需要做的效果,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧
    2022-09-09
  • 詳解Vue3如何加載動態(tài)菜單

    詳解Vue3如何加載動態(tài)菜單

    這篇文章主要為大家詳細介紹了Vue3是如何實現(xiàn)加載動態(tài)菜單功能的,文中的示例代碼講解詳細,對我們學(xué)習(xí)Vue有一定幫助,需要的可以參考一下
    2022-07-07

最新評論

庄河市| 丘北县| 会泽县| 张家港市| 苗栗市| 呼图壁县| 庆阳市| 宾川县| 水富县| 延吉市| 军事| 巍山| 鹤庆县| 怀安县| 义乌市| 汽车| 茶陵县| 松溪县| 蒲城县| 丹凤县| 达拉特旗| 康平县| 陵川县| 桑植县| 崇义县| 黔西| 武强县| 白沙| 宁远县| 博野县| 重庆市| 罗平县| 宁南县| 高雄市| 常熟市| 泸溪县| 察隅县| 华坪县| 三江| 太湖县| 蒙自县|