我在添加到 dayaLayer 时遇到问题。对于 gtm,我使用这个插件,但我不\xe2\x80\x99不明白如何通过组件为其添加 dataLayer。\n我的 nuxt.config fo 插件
\n\nmodules: [\n [\'@nuxtjs/google-tag-manager\', {\n id: \'GTM-xxxxxxxxxx\',\n pageViewEventName: \'nuxtRoute\',\n pageTracking: true,\n layer: \'dataLayer\'\n }]\n ]\nRun Code Online (Sandbox Code Playgroud)\n\n我的组件
\n\nhead() {\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) 我正在寻找一种方法来重定向我的所有 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
欢迎任何见解。谢谢!