vue获取屏幕的实时 宽度 / 高度
mounted () {const that = this;window.onresize = () => {return (() => {window.screenWidth = document.documentElement.clientWidth; //实时宽度window.screenHeight = document.documentElement.clientHeight
·
mounted () {
const that = this;
window.onresize = () => {
return (() => {
window.screenWidth = document.documentElement.clientWidth; //实时宽度
window.screenHeight = document.documentElement.clientHeight; //实时高度
console.log(this.screenWidth, this.screenHeight);
that.screenWidth = window.screenWidth;
that.screenHeight = window.screenHeight;
})();
};
},
获取屏幕的宽度和高度 适用于响应式 用来做判断使用
更多推荐
已为社区贡献2条内容
所有评论(0)