Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Angular 8中使用外部库时出现问题_Angular - Fatal编程技术网

在Angular 8中使用外部库时出现问题

在Angular 8中使用外部库时出现问题,angular,Angular,基本上,我试图在我的angular应用程序中使用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.

基本上,我试图在我的angular应用程序中使用
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>
现在,在我的身份验证组件中,我完成了以下操作

// ...

declare var profitWell: any;

// ...

authenticate() {
   // ...
   profitWell('start', {'user_email': this.email});
}
现在我可以在我的网络中看到正在调用profitWell脚本,但是当我调用profitWell方法时,我得到以下结果

// ...

declare var profitWell: any;

// ...

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


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

您的使用中存在拼写错误。您需要使用like
profitwell
和您使用的
profitwell
。这就是问题所在

declare var profitwell: any;

// ...

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

尝试使用window.profitwell并将window声明为any。@ShabbirDhangot同一问题
window.profitwell
不是一个函数Try w in small。检查js文件的最后一行。我检查了这个js文件,文件中没有profitWell声明。这就是为什么你不能使用。