zoukankan      html  css  js  c++  java
  • navigator.sendBeacon方法可以搜索文档具体用法,它支持的传参形式是有限制的。

    在APP.vue中写页面关闭时触发的方法,

    mounted(){
      //页面打开注册关闭事件
      //unload
      //onbeforeunload
      let url = xxx/xxx/xxx
      window.addEventListener("unload", (event) => {
          navigator.sendBeacon(url , JSON.stringify({
            data:  {
              text: 123
            }
          }));
          window.localStorage.setItem("stored", "1");
          // Cancel the event as stated by the standard.
          event.preventDefault();
          // Chrome requires returnValue to be set.
          event.returnValue = "true";
        });
     },
    

      

     

  • 相关阅读:
    git命令总结
    Junit
    zookeeper--概述
    NIO与Socket
    分区分表
    ThreadLocal
    垃圾收集器
    垃圾收集算法
    主从复制
    Redis--集群
  • 原文地址:https://www.cnblogs.com/sinceForever/p/14525169.html
Copyright © 2011-2022 走看看