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

vuejs关闭浏览器触发事件及切换浏览器触发事件

493 ℃
     
data(){
    return{
        WriteFlagTime:''
    }
},

mounted() {
    window.addEventListener("beforeunload", e => this.beforeunloadHandler(e));
    window.addEventListener("unload", e => this.unloadHandler(e));
},

destroyed() {
    window.removeEventListener("beforeunload", e => this.beforeunloadHandler(e));
    window.removeEventListener("unload", e => this.unloadHandler(e));
},

methods: {
    beforeunloadHandler(e) {
      this.WriteFlagTime = new Date().getTime();
    },
    unloadHandler() {
      this._gap_time = new Date().getTime() - this.WriteFlagTime;
      //判断是窗口关闭还是刷新
      if (this._gap_time <= 5) {
        console.log(Date.now());
      }
    },
    //监听浏览器
    browserMonitor(evt, hidden) {
        if (hidden === false) {
          console.log(Date.now());
        }
    }
}

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

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

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

MacBook电脑(笔记本)Chrome浏览器快捷键汇总(新手必备)

wordpress如何利用php判断浏览器版本

标签: 浏览器

上面是“vuejs关闭浏览器触发事件及切换浏览器触发事件”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。

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

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

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