您当前的位置: 首页 > 

暂无认证

  • 0浏览

    0关注

    92582博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

vue获取屏幕宽高

发布时间:2021-11-12 10:09:09 ,浏览量:0

目录
  • 1、在data中获取
  • 2、在mounted函数中获取
1、在data中获取
data() { return { screenWidth: document.body.clientWidth, // 屏幕宽度 screenHeight: document.body.clientHeight, // 屏幕高度 } } 
2、在mounted函数中获取
mounted() { window.screenWidth = document.body.clientWidth; window.screenHeight = document.body.clientHeight; this.screenWidth = window.screenWidth; this.screenHeight = window.screenHeight; console.log(window.screenWidth); console.log(window.screenHeight); console.log(this.screenWidth); console.log(this.screenHeight); } 
关注
打赏
1653961664
查看更多评论
立即登录/注册

微信扫码登录

0.3750s