在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML/ nuxt.js項(xiàng)目里面如何添加百度統(tǒng)計(jì)代碼

nuxt.js項(xiàng)目里面如何添加百度統(tǒng)計(jì)代碼

nuxt.js項(xiàng)目里面如何添加百度統(tǒng)計(jì)代碼

回答
編輯回答
不二心

NUXT SEO

nuxt.js中添加統(tǒng)計(jì)代碼,添加百度統(tǒng)計(jì),或者google的統(tǒng)計(jì)

添加百度統(tǒng)計(jì)
在 plugins 目錄下創(chuàng)建 plugins/baiduGa.js 文件
plugins/baiduGa.js
export default ({app: {router}, store}) => {
  /* 每次路由變更時(shí)進(jìn)行pv統(tǒng)計(jì) */
  router.afterEach((to, from) => {
    /* 告訴增加一個(gè)PV */
    try {
      window._hmt = window._hmt || []
      window._hmt.push(['_trackPageview', to.fullPath])
    } catch (e) {
    }
  })
}
然后,我們需要告訴 Nuxt.js 將該插件導(dǎo)入主應(yīng)用中,在nuxt.config.js配置如下
nuxt.config.js
head: {
    script: [
     {src: 'https://#/hm.js?****'}, /*引入百度統(tǒng)計(jì)的js*/
    ]
},
plugins: [
   '@/plugins/ga.js', /*百度統(tǒng)計(jì)*/
]


添加google統(tǒng)計(jì) 官方
https://zh.nuxtjs.org/faq/goo...


from https://github.com/WangShuXia...
2018年1月27日 20:39