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