码迷,mamicode.com
首页 > 其他好文 > 详细

vue监听浏览器窗口的变化,随着窗口变化调整里面table的宽高

时间:2018-10-24 15:43:19      阅读:1409      评论:0      收藏:0      [点我收藏+]

标签:浏览器   scree   mount   turn   height   this   res   table   宽高   

1.在data中设置:

1  tableHeight:"500",
2  screenHeight:window.innerHeight,

2.在mounted中设置:

1   mounted() {
2       const that = this
3       window.onresize =()  =>{
4         return (()=>{
5           window.screenHeight = window.innerHeight
6           this.screenHeight = window.screenHeight;
7         })()
8       }
9     },

3.在watch中监听:

1   watch:{
2       screenHeight(val){
3         this.screenHeight = val
4         this.tableHeight = this.screenHeight - 250
5       }
6     },

 

vue监听浏览器窗口的变化,随着窗口变化调整里面table的宽高

标签:浏览器   scree   mount   turn   height   this   res   table   宽高   

原文地址:https://www.cnblogs.com/yangguoe/p/9842504.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!