如何将mailchimp与nuxt js应用程序集成? [英] How to integrate mailchimp with nuxt js app?

查看:73
本文介绍了如何将mailchimp与nuxt js应用程序集成?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将以下脚本嵌入到我在 nuxtjs 应用程序中的组件中.但是由于nuxt对此没有解决方案.想请教vue社区,有没有更好的嵌入外部3rd方js脚本的方法?

I'd like to embed the following script into my component in nuxtjs app. But since nuxt has no solution for this. I'd like to ask the vue community to see if there was a better way of embedding external 3rd party js scripts?

我应该在哪里嵌入这种类型的 scipt?我需要添加什么样的外部配置才能使其工作?

Where should I be embedding this type of scipt? And what sort of external configurations do I need to add to enable this to work?

我尝试直接添加到我的模板中,但似乎不起作用.

I tried adding directly into my template but it doesn't seem to be working.

<script type="text/javascript" src="//downloads.mailchimp.com/js/signup-forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script><script type="text/javascript">require(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us17.list-manage.com","uuid":"XXXXXX","lid":"XXXXXX"}) })</script>

谢谢!

推荐答案

  head() {
    return {
      script: [
        {
          type: "text/javascript", // mailchimp universal script
          src:
            "//downloads.mailchimp.com/js/signup-forms/popup/unique-methods/embed.js",
          "data-dojo-config": "usePlainJson: true, isDebug: false"
        },
        {
          type: "text/javascript", // mailchimp script for specific popup form
          innerHTML: this.getMailchimp
        }
      ],
      __dangerouslyDisableSanitizers: ["script"]
    };
  },

  computed: {
    getMailchimp() {
      if (process.client) {
        return JSON.stringify(
          window.dojoRequire(["mojo/signup-forms/Loader"], function(L) {
            L.start({
              baseUrl: "your base url",
              uuid: "your uuid",
              lid: "your lid",
              uniqueMethods: true
            });
          })
        );
      }
    }
  }

这篇关于如何将mailchimp与nuxt js应用程序集成?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆