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

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

826 ℃
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的各种介绍

标签: 浏览器, 监听

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

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

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

当前位置: 网站首页 > vuejs
本文共计463个字,预计阅读时长4分钟
Trae:新一代免费的AI编程工具

基金从业资格考试题库

一站式备考基金从业资格考试,收录2021-2025年模拟题库!呱呱工具箱

AI工作站

收录全球3800+ 款各行各业AI应用,轻轻松松做事!
生活小工具,收录了80多款小工具
上一篇: 介绍几款带有中国风古韵的免费可商用中文字体
下一篇: 推荐9款支持 Vue3 免费开源的前端 UI 组件库
x 打工人ai神器