el-table根据浏览器动态设置高度

Vue+Element-UI根据浏览器大小动态设置el-table的高度.

效果

在这里插入图片描述

示例代码

<template> 
    <lls-table 
      :data="tableData" 
      :height="tableHeight"> 
    </llst-bale> 
</template> 
export default {
    
     
    data () {
    
     
        return {
    
     
            tableHeight: window.innerHeight - 340, tableData:[]
        } 
    }, 
    created () {
    
     
        window.addEventListener('resize', this.getTableHeight) 
    }, 
    destroyed () {
    
     
        window.removeEventListener('resize', this.getTableHeight) 
    }, 
    methods () {
    
     
        getTableHeight () {
    
     
          this.tableHeight = window.innerHeight - 340 
        }, 
    }, 
} 

猜你喜欢

转载自blog.csdn.net/cuclife/article/details/128478835
今日推荐