0

基本上我正在尝试profitWell在我的角度应用程序中使用脚本这是脚本

<script id="profitwell-js" data-pw-auth="XXX">
        (function(i,s,o,g,r,a,m){i[o]=i[o]||function(){(i[o].q=i[o].q||[]).push(arguments)};
        a=s.createElement(g);m=s.getElementsByTagName(g)[0];a.async=1;a.src=r+'?auth='+
        s.getElementById(o+'-js').getAttribute('data-pw-auth');m.parentNode.insertBefore(a,m);
        })(window,document,'profitwell','script','https://public.profitwell.com/js/profitwell.js');
        profitwell('start', { 'user_email': 'USER_EMAIL_HERE' });
</script>

现在我已经把这个脚本放在<head>我的中index.html并从中删除了profitWell('start'),因为我需要等到用户进行身份验证才能发送 emailAddress

所以我的 index.html 看起来像这样

<head>
<!-- ... -->
   <script id="profitwell-js" data-pw-auth="XXX">
        (function(i,s,o,g,r,a,m){i[o]=i[o]||function(){(i[o].q=i[o].q||[]).push(arguments)};
        a=s.createElement(g);m=s.getElementsByTagName(g)[0];a.async=1;a.src=r+'?auth='+
        s.getElementById(o+'-js').getAttribute('data-pw-auth');m.parentNode.insertBefore(a,m);
        })(window,document,'profitwell','script','https://public.profitwell.com/js/profitwell.js');
  </script>
</head>

现在在我的身份验证组件中,我完成了以下操作

// ...

declare var profitWell: any;

// ...

authenticate() {
   // ...
   profitWell('start', {'user_email': this.email});
}

现在我可以在我的网络中看到正在调用 ProfitWell 脚本,但是当我调用 ProfitWell 方法时,我得到以下信息

profitWell is not defined

现在我的理解是,当我添加declare var profitWell: any好让我使用全局profitWell但我似乎无法让它工作时。

4

1 回答 1

1

您的用法有拼写错误。你需要使用 likeprofitwell和你 used profitWell。这里的利润是问题所在。

declare var profitwell: any;

// ...

authenticate() {
   // ...
   profitwell('start', {'user_email': this.email});
}
于 2019-12-10T05:14:46.093 回答