Commit 632e7d4d0efffd08a89e670df23ac36652153466
1 parent
bcb55fe3
add 官网浏览网站统计
Showing
2 changed files
with
23 additions
and
2 deletions
public/index.html
... | ... | @@ -11,7 +11,9 @@ |
11 | 11 | <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=cuMSxNl5LOY6sf1M3nDGtG6tGXl5a0Bb"></script> |
12 | 12 | <!-- 引入百度地图交通路况文件 --> |
13 | 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 | 17 | </head> |
16 | 18 | <body> |
17 | 19 | <noscript> |
... | ... | @@ -19,5 +21,14 @@ |
19 | 21 | </noscript> |
20 | 22 | <div id="app"></div> |
21 | 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 | 33 | </body> |
23 | 34 | </html> | ... | ... |
src/main.js
... | ... | @@ -43,4 +43,14 @@ new Vue({ |
43 | 43 | router, |
44 | 44 | store, |
45 | 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 | +}); | ... | ... |