Vue获取DOM元素样式和样式更改

如果我们给一个div设定全屏背景图,就需要获取屏幕高度进行赋值:

 
<template>
 <div ref="nana">
  <!-- ... -->
 </div>
</template>
 
<script>
export default {
 mounted () {
 
 
   let w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
   let h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
 
  this.$refs.nana.style.height = h +'px';
 
  }
 
}
 
</script>

 

posted on 2019-05-20 09:41  一只傻阿贝哟  阅读(3767)  评论(0编辑  收藏  举报

导航