问题描述
我目前在带有<script src="https://www.paypal.com/sdk/js?client-id=...
的index.html中包含PayPal JS SDK
declare var paypal: any;
export class BuyComponent implements OnInit {
@ViewChild("paypal",{ static: true }) paypalElement: ElementRef;
paypal
.Buttons({
...
我尝试将其另存为paypal.js
在assets/js
文件夹中,然后在angular.json
中添加
"scripts": [
...,"src/assets/js/paypal.js"
]
但这给了我一个ReferenceError: paypal is not defined
如何在我的Angular代码中将此外部js作为内部文件包括在内?
解决方法
每页加载时,应始终由每个客户端(浏览器)从外部加载并加载paypal sdk js文件
不支持隐藏副本