亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

封裝Table

要在css中設(shè)置table的高度,使數(shù)據(jù)過(guò)多時(shí)出現(xiàn)滾動(dòng)條,將縱向設(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: {
    //動(dòng)態(tài)滾動(dòng)
    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()
          }
        }
      });
    },
    //定時(shí)滾動(dòng)
    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 滾動(dòng)條樣式*/
.table_container /deep/ .ivu-table-body::-webkit-scrollbar {
  /*滾動(dòng)條整體樣式*/
  width: 5px; /*高寬分別對(duì)應(yīng)橫豎滾動(dòng)條的尺寸*/
  height: 3px;
}
.table_container /deep/ .ivu-table-body::-webkit-scrollbar-thumb {
  /*滾動(dòng)條里面小方塊*/
  border-radius: 10px;
  height: 20px;
  -webkit-box-shadow: inset 0 0 5px black;
}
.table_container /deep/ .ivu-table-body::-webkit-scrollbar-track {
  /*滾動(dòng)條里面軌道*/
  -webkit-box-shadow: inset 0 0 5px #6B90B6;
  border-radius: 10px;
  background: #ffffff;
}
</style>

在引用組件的頁(yè)面調(diào)用定時(shí)滾動(dòng)方法

<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;
           //動(dòng)態(tài)滾動(dòng)
          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實(shí)現(xiàn)定時(shí)自動(dòng)滾動(dòng)的文章就介紹到這了,更多相關(guān)vue Table定時(shí)自動(dòng)滾動(dòng)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

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

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

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

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

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

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

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

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

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

    vue打包項(xiàng)目版本號(hào)自加的操作步驟

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

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

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

    詳解Vue前端對(duì)axios的封裝和使用

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

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

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

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

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

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

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

最新評(píng)論