web建站教程
  1. 首页
  2. vuejs
  3. js
  4. 好玩
  5. seo教程
  6. 前端知识
  7. 百度echarts
  8. 更多
    php入门
    nodejs
    mockjs
    reactjs
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站

vuejs监听当前浏览器大小执行

425 ℃
     
data(){
   return {
     screenWidth: document.body.clientWidth
   }
},
mounted() {
    //监听浏览器大小
    let that = this;
    window.addEventListener("resize", function() {
      return (() => {
        window.screenWidth = document.body.clientWidth;
        that.screenWidth = window.screenWidth;
        console.log("that.screenWidth", that.screenWidth);
      })();
    });
},
watch: {
    //防止因为频繁触发 resize 函数,导致页面很卡的问题
    screenWidth(val) {
      if (!this.timer) {
        this.screenWidth = val;
        this.timer = true;
        let that = this;
        setTimeout(function() {
          that.reload();
          that.timer = false;
        }, 400);
      }
    }
}

浏览器网页无法打开一般有哪些原因导致的,解决方法介绍

js如何判断浏览器是否支持html5?

nodejs如何读取/修改/监听文件流

常用浏览器User-Agent的各种介绍

react如何利用addEventListener监听关闭Modal弹框

标签: 浏览器, 监听

上面是“vuejs监听当前浏览器大小执行”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_1801.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 网站首页 > vuejs
本文共计463个字,预计阅读时长4分钟
生活小工具,收录了80多款小工具
上一篇: 推荐一款宝藏型工具应用类网站——一个木匣
下一篇: 推荐一款拥有江西情怀的免费可商用字体——江西拙楷体
x 打工人ai神器