1.main.js引入
var _hmt = _hmt || [];
window._hmt = _hmt;
(function () {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?3adaf*******************079";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
2.router.js使用
router.beforeEach((to, from, next) => {
if (_hmt) {
if (to.path) {
_hmt.push(['_trackPageview', '/#' + to.fullPath]);
}
}
});
网友评论