Commit 632e7d4d0efffd08a89e670df23ac36652153466

Authored by Andy
1 parent bcb55fe3

add 官网浏览网站统计

public/index.html
@@ -11,7 +11,9 @@ @@ -11,7 +11,9 @@
11 <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=cuMSxNl5LOY6sf1M3nDGtG6tGXl5a0Bb"></script> 11 <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=cuMSxNl5LOY6sf1M3nDGtG6tGXl5a0Bb"></script>
12 <!-- 引入百度地图交通路况文件 --> 12 <!-- 引入百度地图交通路况文件 -->
13 <script type="text/javascript" src="http://api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js"></script> 13 <script type="text/javascript" src="http://api.map.baidu.com/library/TrafficControl/1.4/src/TrafficControl_min.js"></script>
14 - 14 + <script>
  15 + var _hmt = _hmt || [];
  16 + </script>
15 </head> 17 </head>
16 <body> 18 <body>
17 <noscript> 19 <noscript>
@@ -19,5 +21,14 @@ @@ -19,5 +21,14 @@
19 </noscript> 21 </noscript>
20 <div id="app"></div> 22 <div id="app"></div>
21 <!-- built files will be auto injected --> 23 <!-- built files will be auto injected -->
  24 + <script>
  25 + var _hmt = _hmt || [];
  26 + (function() {
  27 + var hm = document.createElement("script");
  28 + hm.src = "https://hm.baidu.com/hm.js?ff441428f7563a1f0f442f41f63f3663";
  29 + var s = document.getElementsByTagName("script")[0];
  30 + s.parentNode.insertBefore(hm, s);
  31 + })();
  32 + </script>
22 </body> 33 </body>
23 </html> 34 </html>
src/main.js
@@ -43,4 +43,14 @@ new Vue({ @@ -43,4 +43,14 @@ new Vue({
43 router, 43 router,
44 store, 44 store,
45 render: h => h(App) 45 render: h => h(App)
46 -}) 46 +});
  47 +
  48 +// 加入百度统计
  49 +router.beforeEach((to, from, next) => {
  50 + if (to.path) {
  51 + if (window._hmt) {
  52 + window._hmt.push(['_trackPageview', '/#' + to.fullPath])
  53 + }
  54 + }
  55 + next()
  56 +});