iview/element的table高度动态设置

前言:

       在使用vue的框架的时候,其中列表是大家经常使用的功能,但是放到我们项目中的话,也有很多属性需要我们二次进行改动。

iview:

1、页面上:官方的话是推荐使用数字或者字符串,但我们需要的是动态,所以给他加一个动态值   :height="now_height"  

<Table
      ref="now_table"
      :height="now_height"
    >

</Table>
 data() {
    return {
      now_height: null //table高度
    };
  },

 window.innerHeight  当前页面的高度,

 this.$refs.now_table.$el.offsetTop  拿到的是当前指定table的 top值

我这里 -43 -100 是因为我上面还有导航栏还有别的元素,你可以根据你的实际情况

 mounted() {
    this.now_height = window.innerHeight - this.$refs.now_table.$el.offsetTop - 43 - 100
  },

element:  原理同上

<el-table
      ref="now_table"
      :height="now_height"
    >

</el-table>
 data() {
    return {
      now_height: null //table高度
    };
  },
 mounted() {
    this.now_height = window.innerHeight - this.$refs.now_table.$el.offsetTop - 43 - 100
  },

到此结束!

  • 8
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值