Vue开发页面时自动匹配页面大小宽度的方法

方法写在 watch 当中,因为要监听 initData 中的数据变化 

watch: {
      initData () {
        let H = document.querySelector('.boxShadow')
        H.style.height = ''
        setTimeout(() => {
          console.log(H.offsetHeight)
          if (H.offsetHeight < window.innerHeight) {
            document.body.style.height = window.innerHeight + 'px'
            H.style.height = window.innerHeight - 30 + 'px'
          } else {
            document.body.style.height = H.offsetHeight + 'px'
            H.style.height = ''
          }
        }, 300)
      }
    }

 boxShadow 为定义的类的

<style lang="scss">
  
  .boxShadow{
    padding: 0 16px 10px;
  }
  .el-tabs__item{
    color: #2f353b!important;
    font-size: 16px!important;
  }
  .Information_box{
    width: 100%;
    height: 44px;
    border-bottom: 1px solid #ccc;
  }
  .Information{
    float: left;
    font-size: 16px;
    display: inline-block;
    line-height: 42px;
    border-bottom: 3px solid #42a5f5;
  }
  .el-pagination {
    float: right;
  }
</style>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值