根据友盟官方提示在index.html的body标签末尾加入相关代码后:

 

友盟统计单页面应用vue

 

后来发现,由于项目为单页面应用,在路由发生跳转时(到其他页面了),并不会重新将新页面加入统计中。需要在App.vue页面中,监听路由,当路由发生变化时,将新页面加入统计中。在App.vue中加入以下代码:

 

watch: {
    '$route' () {
      if (window._czc) {
        let location = window.location
        let contentUrl = location.pathname + location.hash
        let refererUrl = '/'
        window._czc.push(['_trackPageview', contentUrl, refererUrl])
      }
    }
  }

 

相关文章:

  • 2021-07-26
  • 2021-07-11
  • 2022-03-02
  • 2022-02-09
  • 2021-04-18
  • 2021-11-01
  • 2022-01-23
猜你喜欢
  • 2021-11-07
  • 2022-12-23
  • 2021-07-17
  • 2021-06-19
  • 2021-07-10
  • 2022-12-23
相关资源
相似解决方案