NUXT [2] -Google Tag Manager(@nuxtjs/gtm)仅在生产中运行
buildModules: ['@nuxtjs/gtm'],
gtm: {
id: 'GTM-5TAAAA',
enabled: () => {
return process.env.ENV === 'production'
}
}
我有开发,舞台和生产环境。
( www.dev-example.com )( www.stage-example.com )()
我希望GTA仅在生产中工作,但总体可以使用。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在PublicRuntimeConfig中移动逻辑(否则该值是在构建时间计算的)
https://github.com/nuxt-comm/nuxt-community/gtm-module/gtm-module-module-untime-untime-untime-untime-untime-untime-untime--untime-untime----- config
Move your logic in publicRuntimeConfig (else the value is computed at build-time)
https://github.com/nuxt-community/gtm-module#runtime-config