监听屏幕处理响应式操作
data:{
isLeftHiden:false,
},
methods:{
togglemobileauto(ismobile){
this.isLeftHiden = ismobile
},
},
beforeMount () {
const {body} = document
const WIDTH = 768;
const RATIO = 3;
const handler = () => {
if (!document.hidden) {
let rect = body.getBoundingClientRect()
console.log(rect,7777);
let isMobile = rect.width - RATIO < WIDTH
this.togglemobileauto(isMobile)
}
}
document.addEventListener('visibilitychange', handler)
window.addEventListener('DOMContentLoaded', handler)
window.addEventListener('resize', handler);
},
记录自己的工作内容