【发布时间】:2020-12-13 22:32:54
【问题描述】:
我目前在 index.html 中包含 PayPal JS SDK 和 <script src="https://www.paypal.com/sdk/js?client-id=...
要在 .ts 文件中呈现按钮,我将使用以下代码:
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的错误
如何将此外部 js 作为内部文件包含在我的 Angular 代码中?
【问题讨论】:
标签: javascript angular paypal paypal-sandbox