vue监听浏览器窗口的变化,随着窗口变化调整里面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     },

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM