1. 程式人生 > >iview table元件高度動態設定

iview table元件高度動態設定

 一、元件

<Table highlight-row border :columns="columns7" :data="data6" ref="table" :height="tableHeight"></Table>

 二、data資料

tableHeight: 450,

三、mounted 鉤子

mounted() {
    // 設定表格高度
    this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 160
  },

window.innerHeight 

是瀏覽器的可用高度

this.$refs.table.$el.offsetTop 是表格距離瀏覽器可用高度頂部的距離