vue单页应用项目加入百度统计代码

登录百度统计管理界面之后把安装代码放到入口index.html对应位置。
然后加入下列代码。
router.beforeEach((to, from, next) => {  
  // 统计代码  
  if (to.path) {  
    window._hmt.push(['_trackPageview', to.fullPath]);  
  }                                                     
  next();                                            
}); 

  

猜你喜欢

转载自www.cnblogs.com/kaibo520/p/10402813.html