小编Ант*_*вко的帖子

如何将 gtm dataLayer 添加到 nuxt.js 组件?

我在添加到 dayaLayer 时遇到问题。对于 gtm,我使用这个插件,但我不\xe2\x80\x99不明白如何通过组件为其添加 dataLayer。\n我的 nuxt.config fo 插件

\n\n
modules: [\n    [\'@nuxtjs/google-tag-manager\', {\n      id: \'GTM-xxxxxxxxxx\',\n      pageViewEventName: \'nuxtRoute\',\n      pageTracking: true,\n      layer: \'dataLayer\'\n    }]\n  ]\n
Run Code Online (Sandbox Code Playgroud)\n\n

我的组件

\n\n
head() {\n    return {\n      title: this.seo.title_meta,\n      meta: [\n        // hid is used as unique identifier. Do not use `vmid` for it as it will not work\n        { hid: \'google-site-verification\', name: \'google-site-verification\', content: \'test\' },\n        { hid: \'description\', name: \'description\', content: this.seo.description_meta }\n      ],\n      __dangerouslyDisableSanitizers: [\'script\'],\n      script: [\n        {\n          innerHTML: JSON.stringify({\n            \'@context\': \'http://schema.org\',\n …
Run Code Online (Sandbox Code Playgroud)

google-tag-manager vue.js nuxt.js

8
推荐指数
1
解决办法
6431
查看次数

如何从nuxt.js中的url中删除尾部斜杠?

我正在寻找一种方法来重定向我的所有 URL,以便它们最后都没有斜线。我试过https://www.npmjs.com/package/@nuxtjs/redirect-module,但它没有正确重定向。

redirect: [
    {
      from: '\/$',
      to: (from, req) => req.url.replace(/\/$/, '')
    }
  ],
Run Code Online (Sandbox Code Playgroud)

例如,要更改这样的 url http://localhost:8080/item/test-slug/ 这个模块将我重定向到http://localhost:8080/item/test-slug/item/test-slug

欢迎任何见解。谢谢!

nuxt.js

4
推荐指数
2
解决办法
4549
查看次数

标签 统计

nuxt.js ×2

google-tag-manager ×1

vue.js ×1