欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue 使用iView組件中的Table實現(xiàn)定時自動滾動效果

 更新時間:2024年05月25日 12:13:01   作者:小鯉魚ya  
要在css中設(shè)置table的高度,使數(shù)據(jù)過多時出現(xiàn)滾動條,將縱向設(shè)置為overflow-y: auto;橫向設(shè)置隱藏 overflow-x: hidden,接下來通過本文介紹vue使用iView組件中的Table實現(xiàn)定時自動滾動效果,需要的朋友可以參考下

封裝Table

要在css中設(shè)置table的高度,使數(shù)據(jù)過多時出現(xiàn)滾動條,將縱向設(shè)置為overflow-y: auto;橫向設(shè)置隱藏 overflow-x: hidden;

<template>
  <div class="table_container">
    <Table :loading="tableLoading" :columns="columns" :data="dataList" ref="tableL"></Table>
  </div>
</template>
<script>
export default {
  name: "tableList",
  props: {
    columns: {
      type: Array,
      default: () => []
    },
    dataList: {
      type: Array,
      default: () => []
    },
  },
  data () {
    return {
      showContentHeight: 0,
      tableBodyHeight: 0,
      tableLoading: false,
    }
  },
  methods: {
    //動態(tài)滾動
    dynamicScroll() {
      let that = this
      this.$nextTick(() => {
        clearInterval(this.timer)
        const table = this.$refs.tableL;
        let tableBody = table.$el.__vue__.$refs.body;
        if (tableBody) {
          let showContentHeight = tableBody.offsetHeight;
          let tableBodyHeight = tableBody.scrollHeight;
          that.showContentHeight = showContentHeight
          that.tableBodyHeight = tableBodyHeight
          if(tableBodyHeight > showContentHeight) {
            that.timerScroll()
          }
        }
      });
    },
    //定時滾動
    timerScroll() {
      let that = this
      const tmpTimer = setInterval(() => {
        const table = that.$refs.tableL;
        let tableBody = table.$el.__vue__.$refs.body;
        if (tableBody) {
          let canScrollHeight = that.tableBodyHeight - that.showContentHeight
          let scrollTop = tableBody.scrollTop
          console.log('scrollTop', scrollTop)
          scrollTop += that.showContentHeight;
          if(scrollTop > canScrollHeight) {
            scrollTop = canScrollHeight
          }
          tableBody.scrollTop = scrollTop;
        }
      }, 5 * 1000);
      this.timer = tmpTimer
      this.$once("hook:beforeDestroy", () => {
        clearInterval(tmpTimer);
      });
    }
  },
}
</script>
<style scoped lang="less">
.table_container {
  height: 100%;
}
.table_container /deep/ .ivu-table-wrapper {
  height: 100%;
  border: none;
  border-bottom: 0;
  border-right: 0;
}
.table_container /deep/ .ivu-table-body {
  height: calc(100% - 40px);	//減掉表頭的高度
  overflow-x: hidden;
  overflow-y: auto;
}
.table_container /deep/ .ivu-table-column-center {
  background-color: #39698D;
  color: white;
}
.table_container /deep/ tbody .ivu-table-column-center {
  color: #89D5EA;
}
.table_container /deep/ .ivu-table {
  background-color:rgba(255,255,255, 0);
  color: #89D5EA;
}
.table_container /deep/ .ivu-table td {
  background-color:rgba(255,255,255, 0);
  border-bottom: 1px solid #496893;
}
.table_container /deep/ .ivu-table-tip {
  color: #89D5EA;
}
.table_container /deep/ .ivu-table:before,.table_container /deep/ .ivu-table:after {
  background-color: rgba(255,255,255, 0);
}
.table_container /deep/ .ivu-table th {
  border-bottom: none;
}
/** .ivu-table-body 滾動條樣式*/
.table_container /deep/ .ivu-table-body::-webkit-scrollbar {
  /*滾動條整體樣式*/
  width: 5px; /*高寬分別對應(yīng)橫豎滾動條的尺寸*/
  height: 3px;
}
.table_container /deep/ .ivu-table-body::-webkit-scrollbar-thumb {
  /*滾動條里面小方塊*/
  border-radius: 10px;
  height: 20px;
  -webkit-box-shadow: inset 0 0 5px black;
}
.table_container /deep/ .ivu-table-body::-webkit-scrollbar-track {
  /*滾動條里面軌道*/
  -webkit-box-shadow: inset 0 0 5px #6B90B6;
  border-radius: 10px;
  background: #ffffff;
}
</style>

在引用組件的頁面調(diào)用定時滾動方法

<template>
  <div class="layout">
    <table-list ref="tableList" :columns="columns" :data-list="warehouseList"/>
  </div>
</template>
<script>
import { columns } from './config'
import tableList from "@/components/tableList";
export default {
  name: "board",
  components: {
    tableList,
  },
  data () {
    return {
      columns,
      warehouseList: [],
      resultData: {},
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    getData() {
      getWarehouseList({}).then(res => {
        console.log('getWarehouseList', res)
        if(res.success) {
          this.resultData = res.result
          this.warehouseList = res.result.warehouseList
          const tableList = this.$refs.tableList;
           //動態(tài)滾動
          tableList.dynamicScroll()
        }
      })
    }
  }
}
</script>
<style scoped lang="less">
.layout {
  width: 100%;
  height: 100%;
  background:url("../../../assets/prod_board.png") no-repeat center -2px;
  background-size: 100% 100%;
  color: #fff;
}
</style>

到此這篇關(guān)于vue 使用iView組件中的Table實現(xiàn)定時自動滾動的文章就介紹到這了,更多相關(guān)vue Table定時自動滾動內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 淺析Vue3中useRouter怎么在Vue組件外使用

    淺析Vue3中useRouter怎么在Vue組件外使用

    useRouter?是?Vue?3?Composition?API?中的鉤子(hook),它只能在?Vue?組件中使用,本文主要來和大家探討一下如何讓他在組件外使用,感興趣的可以了解下
    2024-11-11
  • 詳解vue-cli項目中用json-sever搭建mock服務(wù)器

    詳解vue-cli項目中用json-sever搭建mock服務(wù)器

    這篇文章主要介紹了詳解vue-cli項目中用json-sever搭建mock服務(wù)器,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-11-11
  • VUE3使用JSON編輯器的詳細(xì)圖文教程

    VUE3使用JSON編輯器的詳細(xì)圖文教程

    最近項目中有用到j(luò)son編輯器,我選用了這款vue的編輯器,看起來也是比較簡潔,接下來就具體介紹一下它,下面這篇文章主要給大家介紹了關(guān)于VUE3使用JSON編輯器的詳細(xì)圖文教程,需要的朋友可以參考下
    2023-04-04
  • 分享Vue組件傳值的幾種常用方式(二)

    分享Vue組件傳值的幾種常用方式(二)

    這篇文章主要介紹了分享Vue組件傳值的幾種常用方式,文章圍繞主題斬開詳細(xì)的內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下
    2022-09-09
  • vue打包項目版本號自加的操作步驟

    vue打包項目版本號自加的操作步驟

    項目每次打包后都需要改動項目版本號,這個改動每次都需要在package.json中修改version,比較麻煩,到底有沒有一種打包后版本號自加的辦法,這篇文章主要介紹了vue打包項目版本號自加的步驟,需要的朋友可以參考下
    2022-09-09
  • vue.js路由跳轉(zhuǎn)詳解

    vue.js路由跳轉(zhuǎn)詳解

    這篇文章主要為大家詳細(xì)介紹了vue.js路由跳轉(zhuǎn)的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-08-08
  • 詳解Vue前端對axios的封裝和使用

    詳解Vue前端對axios的封裝和使用

    這篇文章主要介紹了Vue前端對axios的封裝和使用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • vue?結(jié)合webpack的初級使用指南小白學(xué)習(xí)篇

    vue?結(jié)合webpack的初級使用指南小白學(xué)習(xí)篇

    這篇文章主要為大家介紹了vue?結(jié)合webpack的初級使用指南非常適合入門webpack的小白學(xué)習(xí),有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-05-05
  • vue3使用高德地圖進行軌跡繪制及播放代碼示例

    vue3使用高德地圖進行軌跡繪制及播放代碼示例

    這篇文章主要介紹了如何定義地圖容器及操作按鈕,使用高德地圖API進行軌跡繪制及播放的方法,并強調(diào)了界面樣式的重要性,高德地圖API的使用需要注冊獲取key,并且設(shè)置了地圖容器的大小,需要的朋友可以參考下
    2024-11-11
  • vue中的v-if和v-show的區(qū)別詳解

    vue中的v-if和v-show的區(qū)別詳解

    這篇文章主要介紹了vue中的v-if和v-show的區(qū)別詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-09-09

最新評論