vue 百度統計埋點


1. 入口文件index.html文件<head>標簽里面添加下面代碼。

<script>
        var _hmt = _hmt || [];
        (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?df8135cf2470a26f8892c6ede9a07849";
        var s = document.getElementsByTagName("script")[0]; 
        s.parentNode.insertBefore(hm, s);
        })();
    </script>

2. main.js文件添加下面代碼。

router.beforeEach((to, from, next) => {
  if (to.path) {
    if(window._hmt){
      _hmt.push(['_trackPageview', '/#' + to.fullPath]);
    }
  }
  next();
});

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM